﻿namespace com.stifel.ServerBuildMgmt.BuildMgmtApprovedInfo
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Web;
    using System.Web.Caching;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using com.stifel.Extensions.DoubleExtensions;
    using com.stifel.Extensions.ObjectExtensions;
    using com.stifel.Extensions.SharePointExtensions;
    using com.stifel.Extensions.StringExtensions;
    using com.stifel.ServerBuildMgmtDao;
    using com.stifel.SharePoint;
    using com.stifel.Web;

    using Microsoft.SharePoint;

    public partial class BuildMgmtApprovedInfoUserControl
    {
        #region Fields

        const string Approve = "Approve";
        const string ApproveMsg = "Servers Approved. User Who Requested These Will be Notified";
        const string Reject = "Reject";
        const string RejectedMsg = "Servers Rejected. User Who Requested These Will be Notified";

        List<CheckBox> _cbListVirtualHours;
        List<CheckBox> _cbListAgentHours;
        List<RadioButton> _rbListIncremental;
        List<RadioButton> _rbListFull;
        string _sitecollectionurl;
        string _UrlReferrer;

        #endregion Fields

        #region Properties

        List<CheckBox> cbListVirtualHours
        {
            get
            {
                if ( _cbListVirtualHours == null )
                    _cbListVirtualHours = new CheckBox[ ] { uiCbViSu, uiCbViMo, uiCbViTu, uiCbViWe, uiCbViTh, uiCbViFr, uiCbViSa }.ToList( );
                return _cbListVirtualHours;
            }
        }

        List<CheckBox> cbListAgentHours
        {
            get
            {
                if ( _cbListAgentHours == null )
                    _cbListAgentHours = new CheckBox[ ] { uiCbAgSu, uiCbAgMo, uiCbAgTu, uiCbAgWe, uiCbAgTh, uiCbAgFr, uiCbAgSa }.ToList( );
                return _cbListAgentHours;
            }
        }

        List<RadioButton> rbListIncrementalDays
        {
            get
            {
                if ( _rbListIncremental == null )
                    _rbListIncremental = new RadioButton[ ] { uiRbSuIncremental, uiRbMoIncremental, uiRbTuIncremental, uiRbWeIncremental, uiRbThIncremental, uiRbFrIncremental, uiRbSaIncremental }.ToList( );
                return _rbListIncremental;
            }
        }

        List<RadioButton> rbListFullDays
        {
            get
            {
                if ( _rbListFull == null )
                    _rbListFull = new RadioButton[ ] { uiRbSuFull, uiRbMoFull, uiRbTuFull, uiRbWeFull, uiRbThFull, uiRbFrFull, uiRbSaFull }.ToList( );
                return _rbListFull;
            }
        }

        string sitecollectionurl
        {
            get
            {
                if ( string.IsNullOrEmpty( _sitecollectionurl ) )
                {
                    SPSite spSite = SPContext.Current.Site;
                    _sitecollectionurl = spSite.Url;
                }
                return _sitecollectionurl;
            }
        }

        int summaryRow
        {
            get;
            set;
        }

        string UrlReferrer
        {
            get
            {
                if ( string.IsNullOrEmpty( _UrlReferrer ) )
                    _UrlReferrer = ( string ) Page.Cache.Get( CacheKey.UrlReferrer );
                if ( string.IsNullOrEmpty( _UrlReferrer ) )
                    setUrlReferrer( );
                return _UrlReferrer;
            }
            set
            {
                _UrlReferrer = value;
                addToCache( CacheKey.UrlReferrer, value );
            }
        }

        #endregion Properties

        #region Methods

        void LoadTabsOnClickOkButtonForEditAndCopy( )
        {
            if ( uiHiddenEditOrCopyModeFlag.Value.FromBase64String( ).Equals( "yes", StringComparison.InvariantCultureIgnoreCase ) )
            {
                LoadClass lcEditOrCopy = uiHiddenLoadCForEditAndCopy.Value.FromBase64String( ).DeserializeFromXml<LoadClass>( );
                ServerValues v = uiHiddenCurrentRequestValues.Value.FromBase64String( ).DeserializeFromXml<ServerValues>( );
                SerializableStifelOS p = uiValOperatingSystem.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( );
                if ( lcEditOrCopy.isNetworkConnectionActivated == false )
                {
                    LoadNetworkConnectionsViewForEditAndCopy( v, p );
                }
                if ( lcEditOrCopy.isDisasterRecovaryActivated == false )
                {
                    LoadDisasterRecoveryViewForEditAndCopy( v );
                }
                if ( lcEditOrCopy.isServerRolesActivated == false )
                {
                    LoadServerRolesViewForEditAndCopy( p, v );
                }
                if ( lcEditOrCopy.isServerRolesActivated == false )
                {
                    uiRolesForAccess_Load( );
                }
                if ( lcEditOrCopy.isBackupActivated == false )
                {
                    setBackupSchedule( v.BackupSchedule );
                }
                uiHiddenEditOrCopyModeFlag.Value = "no".ToBase64String( );
            }

        }

        void LoadNetworkConnectionsViewForEditAndCopy( ServerValues v, SerializableStifelOS p )
        {
            //Setting Values To UI from Network Connection

            #region Setting Values To UI from Network Connection

            uiValNetworkConnectionsNumber_Load( v.NetworkConnections.Number, p );
            uiValNetworkConnectionsType_Load( v.NetworkConnections.Type, p );
            if ( v.NetworkConnections.OtherDescription != null )
            {
                uiLblNetworkConnectionTypeOther.Visible = true;
                uiValNetworkConnectionTypeOther.Visible = true;
                uiNetworkConnectionDescriptionFlag.Visible = true;
            }
            else
            {
                uiLblNetworkConnectionTypeOther.Visible = false;
                uiValNetworkConnectionTypeOther.Visible = false;
                uiNetworkConnectionDescriptionFlag.Visible = false;
            }
            uiValNetworkConnectionTypeOther.Text = v.NetworkConnections.OtherDescription;
            uiDdlVlanCluster_Load( uiValNetworkConnectionsType.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelNetworkConnectionTypeSerializable>( ), v.NetworkConnections.ClusterVlan );
            if ( ( uiDdlLocation.SelectedItem.Text == string.Empty ) || ( uiDdlLocation.SelectedItem.Text == null ) )
            {
                hideVlanInfo( );
                uiDdlVlan_Load( string.Empty, uiDdlVlanClusters.SelectedItem.Text.Trim( ), v.NetworkConnections.VlanInfo );
            }
            else
            {
                showVlanInfo( );
                uiDdlVlan_Load( uiDdlLocation.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelVirtualServerLocationSerizable>( ).City.Trim( ), uiDdlVlanClusters.SelectedItem.Text.Trim( ), v.NetworkConnections.VlanInfo );
            }
            uiTbReasonNc.Text = v.NetworkConnections.Reason;
            SetNCReasonVisibleOrInvisible( );

            #endregion
        }

        void LoadDisasterRecoveryViewForEditAndCopy( ServerValues v )
        {
            //Setting Value To UI from Disaster Recovery

            #region Setting Value To UI from Disaster Recovery

            uiValDisasterRecoveryReplicationType_Load( v.DisasterRecovery.ReplicationType );
            if ( v.DisasterRecovery.Requested == true )
            {
                uiValDisasterRecoveryRequested.Checked = true;
                setDisasterRecovey( );
            }
            else
            {
                uiValDisasterRecoveryRequested.Checked = false;
                setDisasterRecovey( );
            }

            if ( ( v.DisasterRecovery.Other != null ) && ( v.DisasterRecovery.Other != string.Empty ) && ( uiValDisasterRecoveryRequested.Checked == true ) )
            {
                uiLblDisasterRecoveryReplicationTypeOther.Visible = true;
                uiValDisasterRecoveryReplicationTypeOther.Visible = true;
                uiDisasterRecoveryFlag.Visible = true;
            }
            else
            {
                uiLblDisasterRecoveryReplicationTypeOther.Visible = false;
                uiValDisasterRecoveryReplicationTypeOther.Visible = false;
                uiDisasterRecoveryFlag.Visible = false;
            }
            uiValDisasterRecoveryReplicationTypeOther.Text = v.DisasterRecovery.Other;

            #endregion
        }

        void LoadServerRolesViewForEditAndCopy( SerializableStifelOS p, ServerValues v )
        {
            //Setting Values To UI from Server Roles

            #region Setting Values To UI from Server Roles

            if ( p.Server.Value == true )
            {
                uiBtnServerRoles.Enabled = true;
            }
            else
            {
                uiBtnServerRoles.Enabled = false;
            }

            uiRoles_Load( p, v.ServerRolesAndSubRoles );

            //uiRoles_Load( v.ServerRoles.ServerRole, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ), v.ServerRoles.ServerSubRoles );

            #endregion
        }

        public bool isNCReasonValidated( )
        {
            bool ok = true;
            if ( uiValNetworkConnectionsNumber.SelectedItem != null )
            {
                if ( uiValNetworkConnectionsNumber.SelectedItem.Text.ToInt32( ) > 1 )
                {
                    if ( ( uiTbReasonNc.Text.Trim( ) == string.Empty ) || ( uiTbReasonNc.Text.Trim( ) == null ) )
                    {
                        ok = false;
                    }
                }
            }
            return ( ok );
        }

        public void SetNCReasonVisibleOrInvisible( )
        {
            if ( uiValNetworkConnectionsNumber.SelectedItem.Text.ToInt32( ) > 1 )
            {
                uiLitReasonNc.Visible = true;
                uiTbReasonNc.Visible = true;
            }
            else
            {
                uiNcReasonErrorMsg.Text = string.Empty;
                uiLitReasonNc.Visible = false;
                uiTbReasonNc.Visible = false;
            }
        }

        public void AddRequestToList( StifelVirtualServerRequest request )
        {
            StifelServerBuildDao dao = new StifelServerBuildDao( );
            StifelVirtualServerRequest AddedRequest = dao.Upsert( request );
            string absUrl = getUrl( );
            Page.Response.Redirect( absUrl.Append( "?ItemGuid=" + AddedRequest.UniqueId.ToString( ) ) );
        }

        public string AddRequestToListButNoRedirect( StifelVirtualServerRequest request )
        {
            StifelServerBuildDao dao = new StifelServerBuildDao( );
            StifelVirtualServerRequest AddedRequest = dao.Upsert( request );
            string absUrl = getUrl( );
            return ( absUrl.Append( "?ItemGuid=" + AddedRequest.UniqueId.ToString( ) ) );
        }

        public StifelVirtualServerRequest getRequestInfo( )
        {
            Guid ItemGuid = HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( );
            StifelServerBuildDao dao = new StifelServerBuildDao( );
            StifelVirtualServerRequest request = dao.getRequestFromListUsingGUID( ItemGuid );
            if ( request != null )
            {
                VirtualServerCollectionClass v = new VirtualServerCollectionClass( );
                foreach ( RepeaterItem r in myRepeater.Items )
                {
                    HiddenField hiddenField = ( HiddenField ) r.FindControl( "valuePart" );
                    v.virtualServerCollection.Add( hiddenField.Value.FromBase64String( ).DeserializeFromXml<ServerValues>( ) );
                }
                request.SerializedVirtualServerRequest = request.SerializeVirtualServerCollectionClass( v );
            }
            return ( request );
        }

        public void Mode( string mode, string e_command_argument )
        {
            AddPanel objAddPanel;
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            objAddPanel.AccessCheckForDummmyValues = 0;
            if ( mode.Equals( "edit", StringComparison.InvariantCultureIgnoreCase ) )
            {
                objAddPanel.isEditMode = true;
            }
            if ( mode.Equals( "copy", StringComparison.InvariantCultureIgnoreCase ) )
            {
                objAddPanel.isCopyMode = true;
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
            setDeleteRepeaterBindingR( e_command_argument );

            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            objAddPanel.currentRepeaterBindingR = objAddPanel.referenceRepeaterBindingR;
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );

            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            objAddPanel.currentUIContentValueV = getValueAsObject( objAddPanel.currentRepeaterBindingR.value );
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );

            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            setUIFromValues( getValueAsObject( objAddPanel.currentRepeaterBindingR.value ) );
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            setAccessUIFromValues( objAddPanel.currentUIContentValueV );
            objAddPanel.editModeTempServerName = uiValServerName.Text;
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
            setDefaultButton( );
            uiApproved.Visible = false;
            uiApprovedUpdate.Visible = true;
        }

        public void PageLoadNewRequest( )
        {
            AddPanel objAddPanel = new AddPanel( );
            uiApprovedUpdate.Visible = false;
            uiApproved.Visible = true;
            myRepeater.DataSource = objAddPanel.repeaterBinding;
            myRepeater.DataBind( );
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        public void SaveServers( )
        {
            if ( HttpContext.Current.Request.QueryString[ "ItemGuid" ] == null )
            {
                StifelVirtualServerRequest request = setRequestInfo( );
                request.SetForApproveSave( );
                AddRequestToList( request );
            }
            else
            {
                StifelVirtualServerRequest request = getRequestInfo( );
                request.SetForApproveSave( );
                AddRequestToList( request );
            }
        }

        public void setControlsToDefault( )
        {
            uiValServerName.Text = string.Empty;
            uiValInstallUpdates.Checked = false;
            uiValReplaceExisting.Checked = false;
            uiValNameExistingServer.Text = string.Empty;
            uiValNetworkConnectionTypeOther.Text = string.Empty;
            uiValDisasterRecoveryRequested.Checked = false;
            uiValDisasterRecoveryReplicationTypeOther.Text = string.Empty;
            accessRepeater.DataSource = null;
            accessRepeater.DataBind( );
            uiValNotes.Text = string.Empty;
        }

        public void setDeleteRepeaterBindingR( string val )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            foreach ( RepeaterBinding r in objAddPanel.repeaterBinding )
            {
                if ( r.value.Equals( val ) )
                {
                    objAddPanel.referenceRepeaterBindingR = r;
                }
            }
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        public StifelVirtualServerRequest setRequestInfo( )
        {
            VirtualServerCollectionClass v = new VirtualServerCollectionClass( );
            foreach ( RepeaterItem r in myRepeater.Items )
            {
                HiddenField hiddenField = ( HiddenField ) r.FindControl( "valuePart" );
                v.virtualServerCollection.Add( hiddenField.Value.FromBase64String( ).DeserializeFromXml<ServerValues>( ) );
            }
            StifelVirtualServerRequest request = new StifelVirtualServerRequest( );
            request.ActivityAuditLog = string.Empty;
            request.SerializedVirtualServerRequest = request.SerializeVirtualServerCollectionClass( v );
            return ( request );
        }

        public void SubmitServers( )
        {
            string redirector = string.Empty;
            if ( HttpContext.Current.Request.QueryString[ "ItemGuid" ] == null )
            {
                string msg = string.Empty;
                if ( uiDropDownStatus.SelectedItem.Text == string.Empty )
                {
                    msg = "Please Select Status .. ";
                    adjustUIOnLoad( msg, true );
                }
                if ( uiDropDownStatus.SelectedItem.Text.Equals( Approve, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    StifelVirtualServerRequest request = setRequestInfo( );
                    request.SetForRequestApprove( );
                    redirector = AddRequestToListButNoRedirect( request );
                    msg = ApproveMsg;
                    adjustUIOnLoad( msg, false );
                }
                if ( uiDropDownStatus.SelectedItem.Text.Equals( Reject, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    StifelVirtualServerRequest request = setRequestInfo( );
                    request.SetRequestRejected( );
                    redirector = AddRequestToListButNoRedirect( request );
                    msg = RejectedMsg;
                    adjustUIOnLoad( msg, false );
                }
            }
            else
            {
                string msg = string.Empty;
                if ( uiDropDownStatus.SelectedItem.Text == string.Empty )
                {
                    msg = "Please Select Status .. ";
                    adjustUIOnLoad( msg, true );
                }
                if ( uiDropDownStatus.SelectedItem.Text.Equals( Approve, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    StifelVirtualServerRequest request = getRequestInfo( );
                    request.SetForRequestApprove( );
                    redirector = AddRequestToListButNoRedirect( request );
                    msg = ApproveMsg;
                    adjustUIOnLoad( msg, false );
                }
                if ( uiDropDownStatus.SelectedItem.Text.Equals( Reject, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    StifelVirtualServerRequest request = getRequestInfo( );
                    request.SetRequestRejected( );
                    redirector = AddRequestToListButNoRedirect( request );
                    msg = RejectedMsg;
                    adjustUIOnLoad( msg, false );
                }
            }
            if ( ( redirector != null ) && ( redirector != string.Empty ) )
            {
                if ( redirector.Equals( UrlReferrer, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    Page.Response.Redirect( redirector );
                }
                else
                {
                    Page.Response.Redirect( UrlReferrer );
                }
            }
        }

        void addToCache( string key, object value )
        {
            if ( value == null )
                Cache.Remove( key );
            else
                // cache for 10 hours
                Cache.Insert( key, value, null,
                    Cache.NoAbsoluteExpiration,
                    new TimeSpan( 10, 0, 0 ),
                    CacheItemPriority.Normal,
                    new CacheItemRemovedCallback(
                        delegate( string k, object v, CacheItemRemovedReason reason )
                        {
                        } ) );
        }

        void adjustUIOnLoad( string msg, bool val )
        {
            uiLitShowMsg.Text = msg;
            uiLitStatus.Visible = val;
            uiDropDownStatus.Visible = val;
            uiBtnSubmit.Enabled = val;
            uiBtnSave.Enabled = val;
        }

        TableRow buildSummary( TextBox textbox )
        {
            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.ColumnSpan = 2;
            c.CssClass = CssClass.Data;
            c.Controls.Add( new Literal
            {
                Text = textbox.Text.Trim( )
            } );
            r.Cells.Add( c );

            r.CssClass = tableclass( );
            return r;
        }

        TableRow buildSummary( Literal literal, TextBox textbox )
        {
            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.Style.Add( HtmlTextWriterStyle.TextAlign, TextAlign.Left );
            c.CssClass = CssClass.Label;
            c.Controls.Add( new Literal
            {
                Text = literal.Text.TrimEnd( ) + " " + textbox.Text.Trim( )
            } );
            r.Cells.Add( c );
            r.CssClass = tableclass( );
            return r;
        }

        TableRow buildSummary( Literal literal, DropDownList dropdownlist )
        {
            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.Style.Add( HtmlTextWriterStyle.TextAlign, TextAlign.Left );
            c.CssClass = CssClass.Label;
            string test = dropdownlist.SelectedItem.Text.Trim( );
            c.Controls.Add( new Literal
            {
                Text = literal.Text.TrimEnd( ) + " " + dropdownlist.SelectedItem.Text.Trim( )
            } );
            r.Cells.Add( c );
            r.CssClass = tableclass( );
            return r;
        }

        TableRow buildSummary( CheckBoxList checkboxlist )
        {
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );
            foreach ( ListItem item in checkboxlist.Items )
            {
                if ( item.Selected )
                {
                    TableRow row = buildSummary( item.Value );
                    t.Rows.Add( row );
                }
            }

            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.Style.Add( HtmlTextWriterStyle.TextAlign, TextAlign.Left );
            c.Controls.Add( t );
            r.Cells.Add( c );

            return r;
        }

        TableRow buildSummary( string value )
        {
            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.Style.Add( HtmlTextWriterStyle.TextAlign, TextAlign.Left );
            c.CssClass = CssClass.Data;
            c.Controls.Add( new Literal
            {
                Text = value
            } );
            r.Cells.Add( c );

            r.CssClass = tableclass( );
            return r;
        }

        TableRow buildSummary( CheckBox checkbox )
        {
            TableRow r = new TableRow( );
            TableCell c = new TableCell( );
            c.Style.Add( HtmlTextWriterStyle.TextAlign, TextAlign.Left );
            c.ColumnSpan = 2;
            HtmlSpanControl span = new HtmlSpanControl( );
            span.Attributes.Add( "class", CssClass.Label );
            span.Controls.Add( new Literal
            {
                Text = checkbox.Text.Trim( )
            } );
            c.Controls.Add( span );
            span = new HtmlSpanControl( );
            span.Attributes.Add( "class", CssClass.Data );
            span.Controls.Add( new Literal
            {
                Text = checkbox.Checked ? "&nbsp;YES" : "&nbsp;NO"
            } );
            c.Controls.Add( span );
            r.Cells.Add( c );

            r.CssClass = tableclass( );
            return r;
        }

        string checkStatus( string strGUID )
        {
            StifelServerBuildDao dao = new StifelServerBuildDao( );
            StifelVirtualServerRequest r = dao.Get( strGUID.ToGuid( ) );
            r.IsRequestorStarted( );
            if ( r == null )
            {
                return string.Empty;
            }
            else
            {
                return r.RequestorStatus.ToString( );
            }
        }

        void clearHardDriveErrorMsg( )
        {
            foreach ( RepeaterItem r in repeaterHardDrive.Items )
            {
                Label hardDriveValidationMsg = ( Label ) r.FindControl( "uiHardDriveValidationMsg" );
                hardDriveValidationMsg.Text = string.Empty;
            }
        }

        string concatnateWithDelimiterSemiColon( List<string> list )
        {
            string returnString = string.Empty;
            if ( ( list != null ) && ( list.Count != 0 ) )
            {
                foreach ( string s in list )
                {
                    returnString = string.Concat( returnString, s, ";" );
                }
            }
            return ( returnString );
        }

        void flushcache( )
        {
            foreach ( string k in CacheKey.Values )
                Cache.Remove( k );
        }

        List<string> getDriveNames( string defaultDriveName )
        {
            List<string> drives = new List<string>( );
            for ( int i = 0; i < 24; i++ )
            {
                drives.Add( string.Format( "{0}:", Convert.ToChar( 'C' + i ) ) );
            }
            drives.Remove( defaultDriveName );
            return ( drives );
        }

        List<string> getListFromSemiColonConcatnatedString( string concatenatedString )
        {
            List<string> splitStrings = new List<string>( );
            if ( ( concatenatedString != null ) && ( concatenatedString != string.Empty ) )
            {
                char[ ] delimeter = new char[ ] { ';' };
                string[ ] spiltString = concatenatedString.Split( delimeter, StringSplitOptions.RemoveEmptyEntries );
                if ( spiltString.Count( ) != 0 )
                {
                    for ( int i = 0; i < spiltString.Count( ); i++ )
                    {
                        splitStrings.Add( spiltString[ i ] );
                    }
                }
            }
            return ( splitStrings );
        }

        Panel getPanels( )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            //Creting the common panle
            Panel p1 = new Panel
            {
                GroupingText = "Server Summary"
            };

            Label newLabel = new Label( );
            newLabel.Text = string.Concat( objAddPanel.panelServerBasics, objAddPanel.panelHardDrive, objAddPanel.panelNterworkConnection, objAddPanel.panelDisasterRecovery, objAddPanel.panelServerRoles, objAddPanel.panelAccess, objAddPanel.panelBackupSchedule, objAddPanel.panelNotes );
            p1.Controls.Add( newLabel );

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );

            //Returning the string.
            return ( p1 );
        }

        int getSplitCount( string url )
        {
            string[ ] split = url.Split( '?' );
            return ( split.Length );
        }

        string getUrl( string absUrl )
        {
            string[ ] split = absUrl.Split( '?' );
            return ( split[ 0 ].ToString( ) );
        }

        string getUrl( )
        {
            string absUrl = HttpContext.Current.Request.Url.AbsoluteUri;
            string[ ] split = absUrl.Split( '?' );
            return ( split[ 0 ].ToString( ) );
        }

        /**
         * Converting the instance of <UIContentValues> to Base64String and returning it.
        **/
        string getValueAsBase64String( ServerValues v )
        {
            string ret;
            string ret1 = ObjectExtensions.SerializeToXml<ServerValues>( v );
            ret = StringExtensions.ToBase64String( ObjectExtensions.SerializeToXml<ServerValues>( v ) );
            return ret;
        }

        ServerValues getValueAsObject( string value )
        {
            ServerValues v = new ServerValues( );
            v = StringExtensions.DeserializeFromXml<ServerValues>( StringExtensions.FromBase64String( value ) );
            return ( v );
        }

        List<RepeaterItem> hardDriveEmptyValidation( )
        {
            List<RepeaterItem> errorItems = new List<RepeaterItem>( );
            foreach ( RepeaterItem r in repeaterHardDrive.Items )
            {
                DropDownList Drive = ( DropDownList ) r.FindControl( "uidropDownDrive" );
                TextBox Name = ( TextBox ) r.FindControl( "Name" );
                TextBox Size = ( TextBox ) r.FindControl( "uiTbHardDriveSize" );
                if ( ( Drive.SelectedItem.Text.ToString( ) == string.Empty ) && ( Name.Text.ToString( ) == string.Empty ) && ( Size.Text.ToString( ) == string.Empty ) )
                {

                }
                else if ( ( Drive.SelectedItem.Text.ToString( ) != string.Empty ) && ( Name.Text.ToString( ) != string.Empty ) && ( Size.Text.ToString( ) != string.Empty ) )
                {

                }
                else
                {
                    errorItems.Add( r );
                }
            }
            return ( errorItems );
        }

        void hardDriveSetErrorMsg( List<string> driveNames )
        {
            foreach ( RepeaterItem r in repeaterHardDrive.Items )
            {
                DropDownList Drive = ( DropDownList ) r.FindControl( "uidropDownDrive" );
                TextBox Name = ( TextBox ) r.FindControl( "Name" );
                DropDownList Size = ( DropDownList ) r.FindControl( "uidropDownSize" );
                Label hardDriveValidationMsg = ( Label ) r.FindControl( "uiHardDriveValidationMsg" );
                if ( driveNames.Contains( Drive.SelectedItem.Text ) )
                {
                    hardDriveValidationMsg.Text = "Drives Cannot Have Same Name.";
                }
                else
                {
                    hardDriveValidationMsg.Text = string.Empty;
                }
            }
        }

        void hardDriveSetErrorMsg( List<RepeaterItem> emptyHardDrive )
        {
            foreach ( RepeaterItem r in repeaterHardDrive.Items )
            {
                DropDownList Drive = ( DropDownList ) r.FindControl( "uidropDownDrive" );
                TextBox Name = ( TextBox ) r.FindControl( "Name" );
                DropDownList Size = ( DropDownList ) r.FindControl( "uidropDownSize" );
                Label hardDriveValidationMsg = ( Label ) r.FindControl( "uiHardDriveValidationMsg" );
                if ( emptyHardDrive.Contains( r ) )
                {
                    hardDriveValidationMsg.Text = "Incomplete Hard Drive Request";
                }
                else
                {
                    hardDriveValidationMsg.Text = string.Empty;
                }
            }
        }

        List<string> hardDriveValidation( )
        {
            List<string> multipleDriveNames = new List<string>( );
            foreach ( RepeaterItem r in repeaterHardDrive.Items )
            {
                int counter = 0;
                DropDownList Drive = ( DropDownList ) r.FindControl( "uidropDownDrive" );
                if ( Drive.SelectedItem.Text != string.Empty )
                {
                    foreach ( RepeaterItem items in repeaterHardDrive.Items )
                    {
                        DropDownList cmpDrive = ( DropDownList ) items.FindControl( "uidropDownDrive" );
                        if ( Drive.SelectedItem.Text == cmpDrive.SelectedItem.Text )
                        {
                            counter = counter + 1;
                        }
                    }
                    if ( ( counter == 0 ) || ( counter == 1 ) )
                    {
                    }
                    else
                    {
                        multipleDriveNames.Add( Drive.SelectedItem.Text );
                    }
                }
            }
            return ( multipleDriveNames );
        }

        void hideVlanCluters( )
        {
            uiLitVlanClusters.Visible = false;
            uiDdlVlanClusters.Visible = false;
        }

        void hideVlanInfo( )
        {
            uiLitVlan.Visible = false;
            uiDdlVlan.Visible = false;
        }

        bool isBackupValidated( )
        {
            bool DdlBackHours = false;
            bool CblistVirtualOrAgentHours = false;
            if ( uiDdlBackupHours.SelectedItem != null )
            {
                if ( ( uiDdlBackupHours.SelectedItem.Text.Trim( ) == string.Empty ) || ( uiDdlBackupHours.SelectedItem.Text.Trim( ) == null ) )
                {
                    DdlBackHours = false;
                }
                else
                {
                    DdlBackHours = true;
                }
            }
            for ( int i = 0; i < 7; i++ )
            {
                if ( ( cbListAgentHours[ i ].Checked ) || ( cbListVirtualHours[ i ].Checked ) )
                {
                    CblistVirtualOrAgentHours = true;
                }
            }
            //foreach ( CheckBox c in cbListVirtualHours )
            //{
            //    if ( c.Checked )
            //    {
            //        CblistVirtualOrAgentHours = true;
            //    }
            //}
            if ( ( CblistVirtualOrAgentHours == false ) && ( DdlBackHours == false ) )
            {
                return ( true );
            }
            else if ( ( CblistVirtualOrAgentHours == true ) && ( DdlBackHours == true ) )
            {
                return ( true );
            }
            else
            {
                return ( false );
            }
        }

        bool isDisasterRecoveryDscRequired( )
        {
            bool ret = false;
            if ( uiValDisasterRecoveryReplicationType.SelectedItem != null )
            {
                StifelDRReplicationType rt = uiValDisasterRecoveryReplicationType.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelDRReplicationType>( );
                if ( uiValDisasterRecoveryRequested.Checked )
                {
                    if ( rt.DRReplicationTypeDescrRqd.Value == true )
                    {
                        if ( ( uiValDisasterRecoveryReplicationTypeOther.Text == null ) || ( uiValDisasterRecoveryReplicationTypeOther.Text == string.Empty ) )
                        {
                            ret = true;
                        }
                    }
                    else
                    {
                        ret = false;
                    }
                }
                else
                {
                    ret = false;
                }
            }
            return ( ret );
        }

        bool isNetworkConnectionDescriptionRequired( )
        {
            bool ret = false;
            if ( uiValNetworkConnectionsType.SelectedItem != null )
            {
                StifelNetworkConnectionTypeSerializable ntSerilizable = uiValNetworkConnectionsType.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelNetworkConnectionTypeSerializable>( );
                if ( ntSerilizable.ncTypeDscReq == true )
                {
                    if ( ( uiValNetworkConnectionTypeOther.Text == null ) || ( uiValNetworkConnectionTypeOther.Text == string.Empty ) )
                    {
                        ret = true;
                    }
                }
                else
                {
                    ret = false;
                }
            }
            return ( ret );
        }

        bool isReplaceExistingServerChecked( )
        {
            bool ret = false;
            if ( uiValReplaceExisting.Checked == true )
            {
                if ( ( uiValNameExistingServer.Text.Trim( ) == null ) || ( uiValNameExistingServer.Text.Trim( ) == string.Empty ) )
                {
                    ret = true;
                }
            }
            else
            {
                ret = false;
            }
            return ( ret );
        }

        bool isServerNameAlreadyExits( )
        {
            bool ret = false;
            AddPanel objAddPanel;
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( objAddPanel.repeaterBinding.Count == 0 )
            {
                ret = false;
            }
            else
            {
                if ( objAddPanel.isEditMode == false )
                {
                    foreach ( RepeaterBinding r in objAddPanel.repeaterBinding )
                    {
                        if ( r.value.FromBase64String( ).DeserializeFromXml<ServerValues>( ).ServerBasics.ServerName.Trim( ).Equals( uiValServerName.Text.Trim( ), StringComparison.InvariantCultureIgnoreCase ) )
                        {
                            if ( uiValServerName.Text.Trim( ) != string.Empty )
                            {
                                ret = true;
                            }
                        }
                    }
                }
                else
                {
                    if ( uiValServerName.Text.Trim( ).Equals( objAddPanel.editModeTempServerName.Trim( ), StringComparison.InvariantCultureIgnoreCase ) )
                    {
                        ret = false;
                    }
                    else
                    {
                        foreach ( RepeaterBinding r in objAddPanel.repeaterBinding )
                        {
                            if ( r.value.FromBase64String( ).DeserializeFromXml<ServerValues>( ).ServerBasics.ServerName.Trim( ).Equals( uiValServerName.Text.Trim( ), StringComparison.InvariantCultureIgnoreCase ) )
                            {
                                ret = true;
                            }
                        }
                    }
                }
            }
            return ( ret );
        }

        bool isServerNameHavingSpaces( )
        {
            string str = uiValServerName.Text.Trim( );
            if ( str.Trim( ).Contains( " " ) )
            {
                return ( true );
            }
            else
            {
                return ( false );
            }
        }

        void isSomethingChanged( )
        {
            if ( isChanged.Value.Equals( "true", StringComparison.InvariantCultureIgnoreCase ) )
            {
                uiBtnSave.Enabled = true;
            }
            else
            {
                uiBtnSave.Enabled = false;
            }
        }

        //void load( )
        //{
        //    StifelOSDao dao = new StifelOSDao( );
        //    List<StifelOS> list = dao.GetAll( );
        //    uiValOperatingSystem.Items.Clear( );
        //    foreach ( StifelOS o in list )
        //    {
        //        ListItem item = new ListItem( o.Title, o.ToSerializableStifelOS( ).SerializeToXml<SerializableStifelOS>( ).ToBase64String( ) );
        //        item.Selected = o.Default.HasValue ? o.Default.Value : false;
        //        uiValOperatingSystem.Items.Add( item );
        //    }
        //    SerializableStifelOS p = uiValOperatingSystem.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( );
        //    setDisasterRecovey( );
        //    setReplceExistingServer( );
        //    uiValMemory_Load( p );
        //    uiValCPUs_Load( p );
        //    repeaterHardDrive_Load( p );
        //    uiValNetworkConnectionsNumber_Load( p );
        //    uiValNetworkConnectionsType_Load( p );
        //    uiRoles_Load( p );
        //    uiValDisasterRecoveryReplicationType_Load( );
        //    uiRolesForAccess_Load( );
        //    uiUsers.Items.Clear( );
        //    uiUsers.Items.Add( string.Empty );
        //    SPContext.Current.Web.GetAllUsers( ).ForEach( u => uiUsers.Items.Add( new ListItem( u.Name, u.SerializeToXml<SPUserInfoExpanded>( ).ToBase64String( ) ) ) );
        //}
        void navigateToSelectedView( Button button )
        {
            string arg = button.CommandArgument;
            int index = -1;

            for ( int i = 0; i < uiView.Views.Count; i++ )
            {
                View view = uiView.Views[ i ];
                if ( view.ID.Equals( arg, StringComparison.OrdinalIgnoreCase ) )
                {
                    index = i;
                    break;
                }
            }
            uiView.ActiveViewIndex = index >= 0 ? index : uiView.Views.Count - 1;
            foreach ( Control c in uiNavigation.Controls )
            {
                Button b = c as Button;
                if ( b != null )
                {
                    b.Attributes.Remove( Attribute.Current );
                }
            }
            button.Attributes.Add( Attribute.Current, true.ToString( ) );
        }

        void PageLoadApprove( )
        {
            uiApproved.Visible = false;
            uiApprovedUpdate.Visible = false;
            uiPanelShowNoServer.Visible = true;
        }

        string panelsToHtmlString( Panel p )
        {
            //Converting the comman panel to HTML string.
            StringWriter s = new StringWriter( );
            p.RenderControl( new HtmlTextWriter( s ) );
            return ( s.ToString( ) );
        }

        void repeaterHardDrive_Load( SerializableStifelOS value )
        {
            AddPanel objAddPanel;
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            int max = value.MaxHardDrives.HasValue ? value.MaxHardDrives.Value.ToInt32( ) : 1;
            int dftHardDriveSize = value.DftHDSizeGB.HasValue ? value.DftHDSizeGB.Value.ToInt32( ) : 256;
            //int maxHardDriveSize = value.MaxHDSizeGB.HasValue ? value.MaxHDSizeGB.Value.ToInt32( ) : 256;

            objAddPanel.dtfName = value.DftHardDriveLabel != null ? value.DftHardDriveLabel.ToString( ) : "NA";
            objAddPanel.dftDrive = value.DftHardDriveName != null ? value.DftHardDriveName.ToString( ) + ":" : "NA";

            objAddPanel.dftSize = dftHardDriveSize;
            objAddPanel.currentUIContentValueV.DefaultHardDrive = objAddPanel.dftDrive;
            objAddPanel.currentUIContentValueV.DefaultHardDriveName = objAddPanel.dtfName;
            objAddPanel.currentUIContentValueV.DefaultHardDriveSize = objAddPanel.dftSize.ToString( ) + "GB";

            objAddPanel.currentUIContentValueV.HardDrives.Clear( );
            for ( int i = 1; i < max; i += 1 )
            {
                HardDrives h = new HardDrives( );
                h.Name = null;
                objAddPanel.currentUIContentValueV.HardDrives.Add( h );
            }
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );

            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            repeaterHardDrive.DataSource = objAddPanel.currentUIContentValueV.HardDrives;
            repeaterHardDrive.DataBind( );

            List<string> drives = getDriveNames( objAddPanel.dftDrive );
            foreach ( RepeaterItem r in repeaterHardDrive.Items )
            {
                //DropDownList dropdownSize = ( DropDownList ) r.FindControl( "uidropDownSize" );
                DropDownList dropdownDrive = ( DropDownList ) r.FindControl( "uidropDownDrive" );
                RadioButton Dependent = ( RadioButton ) r.FindControl( "uiRbHardDriveDependent" );
                //dropdownSize.Items.Add( string.Empty );
                //for ( int i = dftHardDriveSize; i <= maxHardDriveSize; i += 256 )
                //{
                //    dropdownSize.Items.Add( new ListItem( i.ToString( ), i.ToString( ) ) );
                //}
                Dependent.Checked = true;
                dropdownDrive.Items.Add( string.Empty );
                foreach ( string s in drives )
                {
                    dropdownDrive.Items.Add( new ListItem( s, s ) );
                }
            }
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void repeaterHardDrive_Load( List<HardDrives> harddrives, SerializableStifelOS value )
        {
            AddPanel objAddPanel;
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            int max = value.MaxHardDrives.HasValue ? value.MaxHardDrives.Value.ToInt32( ) : 1;
            if ( max == ( harddrives.Count + 1 ) )
            {
                int dftHardDriveSize = value.DftHDSizeGB.HasValue ? value.DftHDSizeGB.Value.ToInt32( ) : 256;
                //int maxHardDriveSize = value.MaxHDSizeGB.HasValue ? value.MaxHDSizeGB.Value.ToInt32( ) : 256;

                objAddPanel.dtfName = value.DftHardDriveLabel != null ? value.DftHardDriveLabel.ToString( ) : "NA";
                objAddPanel.dftDrive = value.DftHardDriveName != null ? value.DftHardDriveName.ToString( ) + ":" : "NA";
                objAddPanel.dftSize = dftHardDriveSize;

                objAddPanel.currentUIContentValueV.DefaultHardDrive = objAddPanel.dftDrive;
                objAddPanel.currentUIContentValueV.DefaultHardDriveName = objAddPanel.dtfName;
                objAddPanel.currentUIContentValueV.DefaultHardDriveSize = objAddPanel.dftSize.ToString( ) + "GB";

                uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
                objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

                repeaterHardDrive.DataSource = harddrives;
                repeaterHardDrive.DataBind( );

                List<string> drives = getDriveNames( objAddPanel.dftDrive );

                foreach ( RepeaterItem r in repeaterHardDrive.Items )
                {
                    TextBox Name = ( TextBox ) r.FindControl( "Name" );
                    TextBox Size = ( TextBox ) r.FindControl( "uiTbHardDriveSize" );
                    HiddenField hf = ( HiddenField ) r.FindControl( "uiHardDriveNameAndLabel" );
                    RadioButton Dependent = ( RadioButton ) r.FindControl( "uiRbHardDriveDependent" );
                    RadioButton Independent = ( RadioButton ) r.FindControl( "uiRbHardDriveIndependent" );
                    foreach ( HardDrives h in harddrives )
                    {
                        if ( ( h.Drive == hf.Value.ToString( ) ) )
                        {
                            //DropDownList dropdownSize = ( DropDownList ) r.FindControl( "uidropDownSize" );
                            DropDownList dropdownDrive = ( DropDownList ) r.FindControl( "uidropDownDrive" );
                            //dropdownSize.Items.Add( string.Empty );
                            //for ( int i = dftHardDriveSize; i <= maxHardDriveSize; i += 256 )
                            //{
                            //    ListItem l = new ListItem( i.ToString( ), i.ToString( ) );
                            //    l.Selected = i == h.Size;
                            //    dropdownSize.Items.Add( l );
                            //}
                            dropdownDrive.Items.Clear( );
                            dropdownDrive.Items.Add( string.Empty );
                            foreach ( string s in drives )
                            {
                                ListItem l = new ListItem( s, s );
                                l.Selected = s == h.Drive;
                                dropdownDrive.Items.Add( l );
                            }
                            Name.Text = h.Name.Trim( );
                            if ( h.Size == 0 )
                            {
                                Size.Text = string.Empty;
                            }
                            else
                            {
                                Size.Text = h.Size.ToString( );
                            }
                            if ( h.Type.Equals( Dependent.Text.Trim( ), StringComparison.InvariantCultureIgnoreCase ) )
                            {
                                Dependent.Checked = true;
                                Independent.Checked = false;
                            }
                            if ( h.Type.Equals( Independent.Text.Trim( ), StringComparison.InvariantCultureIgnoreCase ) )
                            {
                                Independent.Checked = true;
                                Dependent.Checked = false;
                            }
                        }
                        //if ( ( h.Drive == hf.Value.ToString( ) ) && ( h.Drive == string.Empty ) )
                        //{
                        //    DropDownList dropdownSize = ( DropDownList ) r.FindControl( "uidropDownSize" );
                        //    DropDownList dropdownDrive = ( DropDownList ) r.FindControl( "uidropDownDrive" ); //Modification
                        //    dropdownSize.Items.Clear( );
                        //    dropdownSize.Items.Add( string.Empty );
                        //    //for ( int i = dftHardDriveSize; i <= maxHardDriveSize; i += 256 )
                        //    //{
                        //    //    ListItem l = new ListItem( i.ToString( ), i.ToString( ) );
                        //    //    dropdownSize.Items.Add( l );
                        //    //}
                        //    dropdownDrive.Items.Clear( );
                        //    dropdownDrive.Items.Add( string.Empty );
                        //    foreach ( string s in drives )
                        //    {
                        //        ListItem l = new ListItem( s, s );
                        //        dropdownDrive.Items.Add( l );
                        //    }
                        //}
                    }
                }
                uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
            }
            else
            {
                repeaterHardDrive_Load( value );
            }
        }

        void ServerRoleValidation( )
        {
            foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
            {
                CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
                CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
                Label uiLSpacing = ( Label ) r.FindControl( "uiSpacing" );
                if ( uiCServerRoles.Checked )
                {
                    uiCLSubRoles.Visible = true;
                    uiLSpacing.Visible = true;
                }
                else
                {
                    uiCLSubRoles.Visible = false;
                    uiLSpacing.Visible = false;
                }
            }
        }

        /**
         * This method sets all the current Field Values to the newly created objects of Classes.
         * List of classes :  ServerBasics, HardDrive, NetworkConnections, DisasterRecovery, ServerRoles, Access, Notes
        **/
        void setAccessUIFromValues( ServerValues v )
        {
            uiUsers.Items.Clear( );
            uiUsers.Items.Add( string.Empty );
            ListItem refL = new ListItem( );
            SPContext.Current.Web.GetAllUsers( ).ForEach( u => uiUsers.Items.Add( new ListItem( u.Name, u.SerializeToXml<SPUserInfoExpanded>( ).ToBase64String( ) ) ) );

            foreach ( string li in v.accessUserRoleColl )
            {
                foreach ( ListItem l in uiUsers.Items )
                {
                    if ( li.Equals( l.Text ) )
                    {
                        refL = l;
                    }
                }
                uiUsers.Items.Remove( refL );
            }

            accessRepeater.DataSource = v.Access;
            accessRepeater.DataBind( );
        }

        void setApproveStatus( string ddlVal )
        {
            string msg = string.Empty;
            Guid ItemGuid = HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( );
            StifelServerBuildDao dao = new StifelServerBuildDao( );
            StifelVirtualServerRequest request = dao.getRequestFromListUsingGUID( ItemGuid );
            if ( request != null )
            {
                if ( ddlVal.Equals( Approve, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    request.SetForRequestApprove( );
                    msg = ApproveMsg;
                }
                if ( ddlVal.Equals( Reject, StringComparison.InvariantCultureIgnoreCase ) )
                {
                    request.SetRequestRejected( );
                    msg = RejectedMsg;
                }
                StifelVirtualServerRequest AddedRequest = dao.Upsert( request );
                if ( Page.Request.Url.ToString( ).Equals( UrlReferrer ) )
                {
                    adjustUIOnLoad( msg, false );
                }
                else
                {
                    Page.Response.Redirect( UrlReferrer );
                }
            }
        }

        void setBackupSchedule( )
        {
            uiDdlBackupHours_Load( );
            foreach ( CheckBox c in cbListVirtualHours )
            {
                c.Checked = false;
            }
            foreach ( CheckBox c in cbListAgentHours )
            {
                c.Checked = false;
            }
            foreach ( RadioButton r in rbListIncrementalDays )
            {
                r.Checked = false;
            }
            foreach ( RadioButton r in rbListFullDays )
            {
                r.Checked = true;
            }
        }

        void setBackupSchedule( BackupSchedule bs )
        {
            uiDdlBackupHours_Load( bs.BackupHours );
            foreach ( CheckBox c in cbListVirtualHours )
            {
                c.Checked = false;
            }
            foreach ( CheckBox c in cbListAgentHours )
            {
                c.Checked = false;
            }
            for ( int i = 0; i < 7; i++ )
            {
                rbListFullDays[ i ].Checked = true;
                rbListIncrementalDays[ i ].Checked = false;
            }
            for ( int i = 0; i < 7; i++ )
            {
                if ( bs.BusType[ i ].Virtual.HasValue )
                {
                    if ( bs.BusType[ i ].Virtual.Value == ( DayOfWeek ) i )
                    {
                        cbListVirtualHours[ i ].Checked = true;
                    }
                }
                if ( bs.BusType[ i ].Agent.HasValue )
                {
                    if ( bs.BusType[ i ].Agent.Value == ( DayOfWeek ) i )
                    {
                        cbListAgentHours[ i ].Checked = true;
                    }
                }
                if ( ( bs.BusType[ i ].Virtual.HasValue ) || ( bs.BusType[ i ].Agent.HasValue ) )
                {
                    if ( bs.BusType[ i ].Type.Equals( rbListIncrementalDays[ i ].Text, StringComparison.InvariantCultureIgnoreCase ) )
                    {
                        rbListIncrementalDays[ i ].Checked = true;
                        rbListFullDays[ i ].Checked = false;
                    }
                    if ( bs.BusType[ i ].Type.Equals( rbListFullDays[ i ].Text, StringComparison.InvariantCultureIgnoreCase ) )
                    {
                        rbListFullDays[ i ].Checked = true;
                        rbListIncrementalDays[ i ].Checked = false;
                    }
                }

                //foreach ( DayOfWeek dayHour in dayHours )
                //{
                //    if ( i == ( int ) dayHour )
                //    {
                //        cbListVirtualHours[ i ].Checked = true;
                //    }
                //}
            }
        }

        //void setBackupSchedule( )
        //{
        //    uiDdlBackupHours_Load( );
        //    foreach ( CheckBox c in cbListDayHours )
        //    {
        //        c.Checked = false;
        //    }
        //}

        //void setBackupSchedule( List<DayOfWeek> dayHours, string selectedBackupHours )
        //{
        //    uiDdlBackupHours_Load( selectedBackupHours );
        //    for ( int i = 0; i < 7; i++ )
        //    {
        //        cbListDayHours[ i ].Checked = false;
        //    }
        //    for ( int i = 0; i < 7; i++ )
        //    {
        //        foreach ( DayOfWeek dayHour in dayHours )
        //        {
        //            if ( i == ( int ) dayHour )
        //            {
        //                cbListDayHours[ i ].Checked = true;
        //            }
        //        }
        //    }
        //}

        /**
         * We will e gettig all the panels from AddPanel.
         * Place these panels in caommon <Server Summary> panel.
         * Converted that to HTML String.
         * Returning String.
         * Note : So now this HTML string will be saved to summary of that purticular instance.
        **/
        void setDefaultButton( )
        {
            Button button = uiApprovedUpdate.FindControl( "uiBtnServerBasics" ) as Button;
            navigateToSelectedView( button );
            summarize( button.CommandArgument );
        }

        void setDefaultButton( string control )
        {
            Button button = uiApprovedUpdate.FindControl( control ) as Button;
            navigateToSelectedView( button );
            summarize( button.CommandArgument );
        }

        void setDisasterRecovey( )
        {
            if ( uiValDisasterRecoveryRequested.Checked )
            {
                uiLblDisasterRecoveryReplicationType.Visible = true;
                uiValDisasterRecoveryReplicationType.Visible = true;
                StifelDRReplicationType rt = uiValDisasterRecoveryReplicationType.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelDRReplicationType>( );
                if ( rt.DRReplicationTypeDescrRqd.Value == true )
                {
                    uiValDisasterRecoveryReplicationTypeOther.Visible = true;
                    uiLblDisasterRecoveryReplicationTypeOther.Visible = true;
                    uiDisasterRecoveryFlag.Visible = true;
                }
            }
            else
            {
                uiLblDisasterRecoveryReplicationType.Visible = false;
                uiValDisasterRecoveryReplicationType.Visible = false;
                uiValDisasterRecoveryReplicationTypeOther.Visible = false;
                uiLblDisasterRecoveryReplicationTypeOther.Visible = false;
                uiDisasterRecoveryFlag.Visible = false;
                uiDisasterRecoveryDscMsg.Text = string.Empty;
                uiValDisasterRecoveryReplicationTypeOther.Text = string.Empty;
            }
        }

        void setHardDrives( ServerValues val )
        {
            val.HardDrives.Clear( );
            OriginalRequest test = val.OriginalRequest;
            foreach ( RepeaterItem repItem in repeaterHardDrive.Items )
            {
                TextBox name = ( TextBox ) repItem.FindControl( "Name" );
                TextBox size = ( TextBox ) repItem.FindControl( "uiTbHardDriveSize" );
                DropDownList drive = ( DropDownList ) repItem.FindControl( "uidropDownDrive" );
                RadioButton Dependent = ( RadioButton ) repItem.FindControl( "uiRbHardDriveDependent" );
                RadioButton InDependent = ( RadioButton ) repItem.FindControl( "uiRbHardDriveIndependent" );
                HardDrives h = new HardDrives( );
                h.Drive = drive.Text;
                h.Size = size.Text.ToInt32( );
                h.Name = name.Text;
                if ( Dependent.Checked )
                {
                    h.Type = Dependent.Text.Trim( );
                }
                if ( InDependent.Checked )
                {
                    h.Type = InDependent.Text.Trim( );
                }
                val.HardDrives.Add( h );
            }
        }

        void setReplceExistingServer( )
        {
            if ( uiValReplaceExisting.Checked )
            {
                uiLblNameExistingServer.Visible = true;
                uiValNameExistingServer.Visible = true;
                uiReplaceServerFlag.Visible = true;
                uiReplaceServerValidationMsg.Text = string.Empty;
            }
            else
            {
                uiLblNameExistingServer.Visible = false;
                uiValNameExistingServer.Visible = false;
                uiReplaceServerFlag.Visible = false;
                uiReplaceServerValidationMsg.Text = string.Empty;
            }
        }

        void setSubmitValidation( )
        {
            if ( myRepeater.Items.Count == 0 )
            {
                uiBtnSubmit.Enabled = false;
                uiBtnSave.Enabled = false;
            }
            else
            {
                int counter = 0;
                foreach ( RepeaterItem item in myRepeater.Items )
                {
                    HiddenField h = ( HiddenField ) item.FindControl( "valuePart" );
                    if ( h.Value.FromBase64String( ).DeserializeFromXml<ServerValues>( ).ServerBasics.ServerName.Equals( string.Empty ) )
                    {
                        uiBtnSubmit.Enabled = false;
                    }
                }
                if ( counter == 0 )
                {
                    uiBtnSave.Enabled = true;
                    uiBtnSubmit.Enabled = true;
                }
                else
                {
                    uiBtnSave.Enabled = true;
                    uiBtnSubmit.Enabled = false;
                }
            }
        }

        void settingNestedServerRoles( List<ServerRole> list )
        {
            List<string> serverRoles = new List<string>( );
            List<RolesAndSubRolesBinder> binder = new List<RolesAndSubRolesBinder>( );
            foreach ( ServerRole s in list )
            {
                RolesAndSubRolesBinder r = new RolesAndSubRolesBinder( );
                r.Role = s.Title.Trim();
                r.SubRolesAsString = concatnateWithDelimiterSemiColon( s.Subroles ).ToBase64String( );
                binder.Add( r );
            }
            uiServerRolesRepeater.DataSource = binder;
            uiServerRolesRepeater.DataBind( );
            //List<string> serverRoles = new List<string>( );
            //foreach ( ServerRole s in list )
            //{
            //    serverRoles.Add( s.Title );
            //}
            //uiServerRolesRepeater.DataSource = serverRoles;
            //uiServerRolesRepeater.DataBind( );
            //foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
            //{
            //    CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
            //    CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );

            //    foreach ( ServerRole sr in list )
            //    {
            //        if ( uiCServerRoles.Text.ToString( ) == sr.Title.ToString( ) )
            //        {
            //            List<string> srvSubRoles = new List<string>( );
            //            srvSubRoles = sr.Subroles;
            //            foreach ( string s in srvSubRoles )
            //            {
            //                uiCLSubRoles.Items.Add( s );
            //            }
            //        }
            //    }
            //}
        }

        void setUIFromValues( ServerValues v )
        {
            AddPanel objAddPanel;
            // Setting values to UI from serverBasics

            #region Setting values to UI from serverBasics
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( objAddPanel.isCopyMode == true )
            {
                uiValServerName.Text = string.Empty;
                uiValSeverDescription.Text = string.Empty;
            }
            else
            {
                uiValServerName.Text = v.ServerBasics.ServerName;
                uiValSeverDescription.Text = v.ServerBasics.ServerDescription;
            }
            uiValOperatingSystem_load( v.ServerBasics.OperatingSystem );
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            SerializableStifelOS p = uiValOperatingSystem.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( );
            if ( p.LegacyOS.HasValue )
            {
                if ( p.LegacyOS.Value == true )
                {
                    setOsReasonVisible( );
                    uiTbReasonOs.Text = v.ServerBasics.Reason.Trim( );
                }
                else
                {
                    setOsReasonHide( );
                }
            }
            uiValMemory_Load( v.ServerBasics.MemoryList, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ) );
            uiValCPUs_Load( v.ServerBasics.CPUs, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ) );

            if ( v.ServerBasics.WindowsUpdate == true )
                uiValInstallUpdates.Checked = true;
            else
                uiValInstallUpdates.Checked = false;

            if ( v.ServerBasics.ReplaceServer == true )
            {
                uiValReplaceExisting.Checked = true;
                setReplceExistingServer( );
            }
            else
            {
                uiValReplaceExisting.Checked = false;
                setReplceExistingServer( );
            }

            uiValNameExistingServer.Text = v.ServerBasics.ExistingServerName;
            uiDdlLocation_Load( v.ServerBasics.LocationItemId );

            #endregion

            // Setting values To UI from HardDrive
            #region Setting values To UI from HardDrive

            repeaterHardDrive_Load( v.HardDrives, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ) );
            objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            #endregion

            //Setting Values To UI from Roles In Access.

            #region Setting Values To UI from Roles In Access.

            uiRolesForAccess_Load( );

            #endregion

            //Setting Values In The Hidden Fields On The Page To Use Them Later

            #region Setting Values In The Hidden Fields On The Page To Use Them Later

            uiHiddenEditOrCopyModeFlag.Value = "yes".ToBase64String( );
            uiHiddenCurrentRequestValues.Value = v.SerializeToXml<ServerValues>( ).ToBase64String( );
            LoadClass lcEditOrCopy = new LoadClass
            {
                isBasicActivated = true,
                isHardDriveActivated = true,
                isNetworkConnectionActivated = false,
                isDisasterRecovaryActivated = false,
                isServerRolesActivated = false,
                isAccessActivated = true,
                isBackupActivated = false,
                isNotesActivated = false
            };

            if ( lcEditOrCopy.isNetworkConnectionActivated == false )
            {
                LoadNetworkConnectionsViewForEditAndCopy( v, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ) );
                lcEditOrCopy.isNetworkConnectionActivated = true;
            }
            if ( v.ServerRolesAndSubRoles.Count != 0 )
            {
                if ( lcEditOrCopy.isServerRolesActivated == false )
                {
                    LoadServerRolesViewForEditAndCopy( objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ), v );
                    lcEditOrCopy.isServerRolesActivated = true;
                }
            }

            if ( v.DisasterRecovery.Requested == true )
            {
                if ( lcEditOrCopy.isDisasterRecovaryActivated == false )
                {
                    LoadDisasterRecoveryViewForEditAndCopy( v );
                    lcEditOrCopy.isDisasterRecovaryActivated = true;
                }
            }

            if ( ( v.BackupSchedule.BackupHours != null ) && ( v.BackupSchedule.BackupHours != string.Empty ) )
            {
                if ( lcEditOrCopy.isBackupActivated == false )
                {
                    //Setting Values To UI from Backup Schedule

                    #region Setting Values To UI from Backup Schedule

                    setBackupSchedule( v.BackupSchedule );

                    #endregion

                    lcEditOrCopy.isBackupActivated = true;
                }
            }

            uiHiddenLoadCForEditAndCopy.Value = lcEditOrCopy.SerializeToXml<LoadClass>( ).ToBase64String( );

            #endregion

            ////Setting Values To UI from Network Connection

            //#region Setting Values To UI from Network Connection

            //uiValNetworkConnectionsNumber_Load( v.NetworkConnections.Number, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ) );
            //uiValNetworkConnectionsType_Load( v.NetworkConnections.Type, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ) );
            //if ( v.NetworkConnections.OtherDescription != null )
            //{
            //    uiLblNetworkConnectionTypeOther.Visible = true;
            //    uiValNetworkConnectionTypeOther.Visible = true;
            //    uiNetworkConnectionDescriptionFlag.Visible = true;
            //}
            //else
            //{
            //    uiLblNetworkConnectionTypeOther.Visible = false;
            //    uiValNetworkConnectionTypeOther.Visible = false;
            //    uiNetworkConnectionDescriptionFlag.Visible = false;
            //}
            //uiValNetworkConnectionTypeOther.Text = v.NetworkConnections.OtherDescription;

            //uiDdlVlanCluster_Load( uiValNetworkConnectionsType.SelectedItem.Value.FromBase64String().DeserializeFromXml<StifelNetworkConnectionTypeSerializable>(),v.NetworkConnections.ClusterVlan );
            //if ( ( uiDdlLocation.SelectedItem.Text == string.Empty ) || ( uiDdlLocation.SelectedItem.Text == null ) )
            //{
            //    hideVlanInfo( );
            //    uiDdlVlan_Load( string.Empty, uiDdlVlanClusters.SelectedItem.Text.Trim( ),v.NetworkConnections.VlanInfo);
            //}
            //else
            //{
            //    showVlanInfo( );
            //    uiDdlVlan_Load( uiDdlLocation.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelVirtualServerLocationSerizable>( ).City.Trim( ), uiDdlVlanClusters.SelectedItem.Text.Trim( ),v.NetworkConnections.VlanInfo );
            //}

            //uiTbReasonNc.Text = v.NetworkConnections.Reason;
            //SetNCReasonVisibleOrInvisible( );

            //#endregion

            ////Setting Value To UI from Disaster Recovery

            //#region Setting Value To UI from Disaster Recovery

            //uiValDisasterRecoveryReplicationType_Load( v.DisasterRecovery.ReplicationType );

            //if ( v.DisasterRecovery.Requested == true )
            //{
            //    uiValDisasterRecoveryRequested.Checked = true;
            //    setDisasterRecovey( );
            //}
            //else
            //{
            //    uiValDisasterRecoveryRequested.Checked = false;
            //    setDisasterRecovey( );
            //}
            //if ( ( v.DisasterRecovery.Other != null ) && ( v.DisasterRecovery.Other != string.Empty ) && ( uiValDisasterRecoveryRequested.Checked == true ) )
            //{
            //    uiLblDisasterRecoveryReplicationTypeOther.Visible = true;
            //    uiValDisasterRecoveryReplicationTypeOther.Visible = true;
            //    uiDisasterRecoveryFlag.Visible = true;
            //}
            //else
            //{
            //    uiLblDisasterRecoveryReplicationTypeOther.Visible = false;
            //    uiValDisasterRecoveryReplicationTypeOther.Visible = false;
            //    uiDisasterRecoveryFlag.Visible = false;
            //}
            //uiValDisasterRecoveryReplicationTypeOther.Text = v.DisasterRecovery.Other;

            //#endregion

            ////Setting Values To UI from Server Roles

            //#region Setting Values To UI from Server Roles

            //if ( objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ).Server.Value == true )
            //{
            //    uiBtnServerRoles.Enabled = true;
            //}
            //else
            //{
            //    uiBtnServerRoles.Enabled = false;
            //}

            //uiRoles_Load( objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ), v.ServerRolesAndSubRoles );

            ////uiRoles_Load( v.ServerRoles.ServerRole, objAddPanel.hiddenValOperatingSystem.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ), v.ServerRoles.ServerSubRoles );

            //#endregion

            ////Setting Values To UI from Roles In Access.

            //#region Setting Values To UI from Roles In Access.

            //uiRolesForAccess_Load( );

            //#endregion

            ////Setting Values To UI from Access

            //#region Setting Values To UI from Access

            //#endregion

            ////Setting Values To UI from Backup Schedule

            //#region Setting Values To UI from Backup Schedule

            //setBackupSchedule( v.BackupSchedule.DayHours, v.BackupSchedule.BackupHours );

            //#endregion

            //Setting Values To UI from Notes

            #region Setting Values To UI from Notes

            uiValNotes.Text = v.Notes.Note;

            #endregion

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void SummarizeInOkButton( )
        {
            summarize( uiBtnHardDrives.CommandArgument.ToString( ) );
            summarize( uiBtnNetworkConnections.CommandArgument.ToString( ) );
            summarize( uiBtnDisasterRecovery.CommandArgument.ToString( ) );
            summarize( uiBtnServerRoles.CommandArgument.ToString( ) );
            summarize( uiBtnAccess.CommandArgument.ToString( ) );
            summarize( uiBtnBackup.CommandArgument.ToString( ) );
            summarize( uiBtnNotes.CommandArgument.ToString( ) );
        }

        void setUrlReferrer( )
        {
            if ( Request != null && Request.UrlReferrer != null )
                UrlReferrer = Request.UrlReferrer.ToString( );
            else if ( Request != null )
                UrlReferrer = Request.Url.ToString( );
        }

        void setValues( ServerValues val )
        {
            /**
             * Saving OriginalValues If Modified By Approver.
            **/

            if ( val.OriginalRequest.ServerBasics.ServerName == null )
            {
                val.OriginalRequest.ServerBasics = val.ServerBasics;
                //val.OriginalRequest.ServerRoles = val.ServerRoles;
                val.OriginalRequest.ServerRolesAndSubRoles = val.ServerRolesAndSubRoles;
                val.OriginalRequest.refaccessUserRoleColl = val.refaccessUserRoleColl;
                val.OriginalRequest.refAccess = val.refAccess;
                val.OriginalRequest.BackupSchedule = val.BackupSchedule;
                val.OriginalRequest.Notes = val.Notes;
                val.OriginalRequest.NetworkConnections = val.NetworkConnections;
                if ( val.OriginalRequest.DefaultHardDrive == null )
                {
                    foreach ( HardDrives h in val.HardDrives )
                    {
                        val.OriginalRequest.HardDrives.Add( h );
                    }
                    val.OriginalRequest.DefaultHardDriveSize = val.DefaultHardDriveSize;
                    val.OriginalRequest.DefaultHardDriveName = val.DefaultHardDriveName;
                    val.OriginalRequest.DefaultHardDrive = val.DefaultHardDrive;
                }
                val.OriginalRequest.DisasterRecovery = val.DisasterRecovery;
                val.OriginalRequest.accessUserRoleColl = val.accessUserRoleColl;
                if ( val.OriginalRequest.Access.Count == 0 )
                {
                    foreach ( Access a in val.Access )
                    {
                        val.OriginalRequest.Access.Add( a );
                    }
                }
            }

            //Assigning New Guid To make each server UNIQUE

            val.UniqueCheckGuid = Guid.NewGuid( );

            // Setting values To the ServerBasics

            #region Setting Values to Server Basics

            ServerBasics serverBasics = new ServerBasics( );
            serverBasics.ServerName = uiValServerName.Text.Trim( );
            serverBasics.ServerDescription = uiValSeverDescription.Text.Trim( );
            serverBasics.OperatingSystem = uiValOperatingSystem.SelectedItem.Text;
            if ( uiValOperatingSystem.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( ).LegacyOS.Value == true )
            {
                serverBasics.Reason = uiTbReasonOs.Text.Trim( );
            }
            serverBasics.MemoryList = uiValMemory.SelectedItem.Text.ToInt32( );
            serverBasics.CPUs = uiValCPUs.SelectedItem.Text.ToInt32( );

            if ( uiValInstallUpdates.Checked == true )
                serverBasics.WindowsUpdate = true;
            else
                serverBasics.WindowsUpdate = false;

            if ( uiValReplaceExisting.Checked == true )
                serverBasics.ReplaceServer = true;
            else
                serverBasics.ReplaceServer = false;

            serverBasics.ExistingServerName = uiValNameExistingServer.Text;

            StifelVirtualServerLocationSerizable svslDeserialized = uiDdlLocation.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelVirtualServerLocationSerizable>( );

            if ( svslDeserialized == null )
            {
                serverBasics.LocationCity = string.Empty;
                serverBasics.LocationState = string.Empty;
                serverBasics.LocationTimeZoneId = string.Empty;
                serverBasics.LocationStateAbbrivation = string.Empty;
            }
            else
            {
                serverBasics.LocationCity = svslDeserialized.City;
                serverBasics.LocationState = svslDeserialized.State;
                serverBasics.LocationTimeZoneId = svslDeserialized.TimezoneId;
                serverBasics.LocationItemId = svslDeserialized.UniqueId;
                serverBasics.LocationStateAbbrivation = svslDeserialized.StateAbbrev;
            }

            val.ServerBasics = serverBasics;

            #endregion

            //Setting values To HardDrive

            #region Setting Values to HardDrive

            setHardDrives( val );

            #endregion

            //Setting Values To Network Connection

            #region Setting Values To Network Connection

            NetworkConnection networkConnections = new NetworkConnection( );
            networkConnections.Number = uiValNetworkConnectionsNumber.SelectedItem.Text.ToInt32( );
            networkConnections.Type = uiValNetworkConnectionsType.SelectedItem.Text;
            StifelNetworkConnectionTypeSerializable localRef = uiValNetworkConnectionsType.SelectedItem.Value.ToString( ).FromBase64String( ).DeserializeFromXml<StifelNetworkConnectionTypeSerializable>( );
            if ( localRef.ncTypeDscReq == true )
            {
                networkConnections.OtherDescription = uiValNetworkConnectionTypeOther.Text;
            }
            else
            {
                networkConnections.OtherDescription = null;
            }

            if ( uiValNetworkConnectionsNumber.SelectedItem.Text.ToInt32( ) > 1 )
            {
                networkConnections.Reason = uiTbReasonNc.Text.Trim( );
            }
            else
            {
                networkConnections.Reason = null;
            }

            if ( uiDdlVlanClusters.SelectedItem.Text == string.Empty )
            {
                networkConnections.ClusterVlan = string.Empty;
            }
            else
            {
                networkConnections.ClusterVlan = uiDdlVlanClusters.SelectedItem.Text.Trim( );
            }
            if ( uiDdlVlan.SelectedItem.Text == string.Empty )
            {
                networkConnections.VlanInfo = string.Empty;
                networkConnections.Vlan = string.Empty;
                networkConnections.VlanClusterId = 0;
                networkConnections.VlanClusterTitle = string.Empty;
                networkConnections.VlanId = 0;
                networkConnections.VlanIp = string.Empty;
                networkConnections.LocationId = 0;
                networkConnections.LocationTitle = string.Empty;
            }
            else
            {
                StifelVLANSerializable vlanSerializable = uiDdlVlan.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelVLANSerializable>( );
                networkConnections.VlanInfo = vlanSerializable.stifelVlanInfo;
                networkConnections.Vlan = vlanSerializable.stifelVlanTitle;
                networkConnections.VlanClusterId = vlanSerializable.stifelVlanClusterId;
                networkConnections.VlanClusterTitle = vlanSerializable.stifelVlanClusterTitle;
                networkConnections.VlanId = vlanSerializable.stifelVlanId;
                networkConnections.VlanIp = vlanSerializable.stifelVlanIp;
                networkConnections.LocationId = vlanSerializable.stifelVlanLocationId;
                networkConnections.LocationTitle = vlanSerializable.stifelVlanLocationTitle;
            }

            val.NetworkConnections = networkConnections;

            #endregion

            //Setting Value To Disaster Recovery

            #region Setting Value To Disaster Recovery

            DisasterRecovery disasterRecovery = new DisasterRecovery( );

            if ( uiValDisasterRecoveryRequested.Checked == true )
                disasterRecovery.Requested = true;
            else
                disasterRecovery.Requested = false;

            disasterRecovery.ReplicationType = uiValDisasterRecoveryReplicationType.SelectedItem.Text;
            StifelDRReplicationType drLocalRef = uiValDisasterRecoveryReplicationType.SelectedItem.Value.ToString( ).FromBase64String( ).DeserializeFromXml<StifelDRReplicationType>( );
            if ( drLocalRef.DRReplicationTypeDescrRqd.Value == true )
            {
                disasterRecovery.Other = uiValDisasterRecoveryReplicationTypeOther.Text;
            }
            else
            {
                disasterRecovery.Other = null;
            }
            val.DisasterRecovery = disasterRecovery;

            #endregion

            //Setting Values To Server Roles

            #region Setting Values to Server Roles

            List<ServerRolesAndSubRoles> srasbList = new List<ServerRolesAndSubRoles>( );
            foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
            {
                CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
                CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
                if ( ( uiCLSubRoles.Items.Count != 0 ) && ( uiCLSubRoles != null ) )
                {
                    bool subRolesSelected = false;
                    foreach ( ListItem li in uiCLSubRoles.Items )
                    {
                        if ( li.Selected == true )
                        {
                            subRolesSelected = true;
                        }
                    }
                    if ( subRolesSelected )
                    {
                        ServerRolesAndSubRoles srasb = new ServerRolesAndSubRoles( );
                        srasb.ServerRole = uiCServerRoles.Text.Trim( );
                        foreach ( ListItem li in uiCLSubRoles.Items )
                        {
                            if ( li.Selected )
                            {
                                srasb.SubRoles.Add( li.Text.Trim( ) );
                            }
                        }
                        srasbList.Add( srasb );
                    }
                }
                else
                {
                    if ( uiCServerRoles.Checked )
                    {
                        ServerRolesAndSubRoles srasb = new ServerRolesAndSubRoles( );
                        srasb.ServerRole = uiCServerRoles.Text.Trim( );
                        srasb.SubRoles = null;
                        srasbList.Add( srasb );
                    }
                }
            }

            val.ServerRolesAndSubRoles = srasbList;

            //ServerRoles serverRoles = new ServerRoles( );
            //foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
            //{
            //    CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
            //    CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
            //    if ( uiCServerRoles.Checked )
            //    {
            //        serverRoles.ServerRole.Add( uiCServerRoles.Text );
            //        ServerRolesAndSubRoles serverSubRoles = new ServerRolesAndSubRoles( );
            //        serverSubRoles.ServerRole = uiCServerRoles.Text;
            //        foreach ( ListItem Sbr in uiCLSubRoles.Items )
            //        {
            //            if ( Sbr.Selected )
            //            {
            //                serverSubRoles.SubRoles.Add( Sbr.Text );
            //            }
            //        }
            //        serverRoles.ServerSubRoles.Add( serverSubRoles );
            //    }
            //}

            //val.ServerRoles = serverRoles;

            #endregion

            //Setting Values To Access

            #region Setting Values To Access

            #endregion

            //Setting Values To Backup Schedule

            #region Setting Values To Backup Schedule

            BackupSchedule backupschedule = new BackupSchedule( );

            backupschedule.BackupHours = uiDdlBackupHours.SelectedItem.Text.Trim( );

            for ( int i = 0; i < 7; i++ )
            {
                if ( ( cbListVirtualHours[ i ].Checked ) && ( !cbListAgentHours[ i ].Checked ) )
                {
                    BackUpScheduleType busType = new BackUpScheduleType( );
                    busType.Virtual = ( DayOfWeek ) i;
                    busType.Agent = null;
                    if ( rbListFullDays[ i ].Checked )
                    {
                        busType.Type = rbListFullDays[ i ].Text.Trim( );
                    }
                    if ( rbListIncrementalDays[ i ].Checked )
                    {
                        busType.Type = rbListIncrementalDays[ i ].Text.Trim( );
                    }
                    backupschedule.BusType.Add( busType );
                }
                else if ( ( !cbListVirtualHours[ i ].Checked ) && ( cbListAgentHours[ i ].Checked ) )
                {
                    BackUpScheduleType busType = new BackUpScheduleType( );
                    busType.Virtual = null;
                    busType.Agent = ( DayOfWeek ) i;
                    if ( rbListFullDays[ i ].Checked )
                    {
                        busType.Type = rbListFullDays[ i ].Text.Trim( );
                    }
                    if ( rbListIncrementalDays[ i ].Checked )
                    {
                        busType.Type = rbListIncrementalDays[ i ].Text.Trim( );
                    }
                    backupschedule.BusType.Add( busType );
                }
                else if ( ( cbListVirtualHours[ i ].Checked ) && ( cbListAgentHours[ i ].Checked ) )
                {
                    BackUpScheduleType busType = new BackUpScheduleType( );
                    busType.Virtual = ( DayOfWeek ) i;
                    busType.Agent = ( DayOfWeek ) i;
                    if ( rbListFullDays[ i ].Checked )
                    {
                        busType.Type = rbListFullDays[ i ].Text.Trim( );
                    }
                    if ( rbListIncrementalDays[ i ].Checked )
                    {
                        busType.Type = rbListIncrementalDays[ i ].Text.Trim( );
                    }
                    backupschedule.BusType.Add( busType );
                }
                else if ( ( !cbListVirtualHours[ i ].Checked ) && ( !cbListAgentHours[ i ].Checked ) )
                {
                    BackUpScheduleType busType = new BackUpScheduleType( );
                    busType.Virtual = null;
                    busType.Agent = null;
                    busType.Type = null;
                    backupschedule.BusType.Add( busType );
                }
            }

            val.BackupSchedule = backupschedule;

            #endregion

            //Setting Values To Notes

            #region Setting Values To Notes

            Notes notes = new Notes( );

            notes.Note = uiValNotes.Text;

            val.Notes = notes;

            #endregion
        }

        void showVlanClusters( )
        {
            uiLitVlanClusters.Visible = true;
            uiDdlVlanClusters.Visible = true;
        }

        void showVlanInfo( )
        {
            uiLitVlan.Visible = true;
            uiDdlVlan.Visible = true;
        }

        void summarize( string arg )
        {
            summarize_ServerBasics( arg );
            summarize_HardDrives( arg );
            summarize_NetworkConnections( arg );
            summarize_DisasterRecovery( arg );
            summarize_ServerRoles( arg );
            summarize_Access( arg );
            summarize_BackupSchedule( arg );
            summarize_Notes( arg );
        }

        void summarize( )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( objAddPanel.args == null )
            {
                objAddPanel.args = uiBtnServerBasics.CommandArgument;
            }
            summarize( objAddPanel.args );
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_Access( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( arg.Equals( uiAccess.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = uiPnlAccess.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            foreach ( RepeaterItem item in accessRepeater.Items )
            {
                Literal uiUsers = ( Literal ) item.FindControl( "uiUsers" );
                Literal uiRoles = ( Literal ) item.FindControl( "uiRoles" );
                if ( ( uiUsers.Text != null ) && ( uiRoles.Text != null ) )
                {
                    if ( ( uiUsers.Text != string.Empty ) && ( uiRoles.Text != string.Empty ) )
                    {
                        t.Rows.Add( buildSummary( uiUsers.Text + " : " + uiRoles.Text ) );
                    }
                }
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelAccess = string.Empty;
                uiSummaryAccess.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelAccess = panelsToHtmlString( p );
                uiSummaryAccess.Controls.Clear( );
                uiSummaryAccess.Controls.Add( p );
            }
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_BackupSchedule( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            if ( arg.Equals( uiBackup.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = "Backup Schedule"
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            string s1 = string.Empty;
            string s2 = string.Empty;
            //for ( int i = 0; i < 7; i++ )
            //{
            //    if ( cbListDayHours[ i ].Checked )
            //    {
            //        DayOfWeek dayHours = ( DayOfWeek ) i;
            //        s1 = string.Concat( s1, dayHours.ToString( ), "," );
            //    }
            //}
            for ( int i = 0; i < 7; i++ )
            {
                if ( ( cbListVirtualHours[ i ].Checked ) && ( !cbListAgentHours[ i ].Checked ) )
                {
                    if ( rbListIncrementalDays[ i ].Checked )
                    {
                        DayOfWeek dayHours = ( DayOfWeek ) i;
                        s1 = string.Concat( s1, dayHours.ToString( ) + ", Virtual, Incremental", ";" );
                    }
                    if ( rbListFullDays[ i ].Checked )
                    {
                        DayOfWeek dayHours = ( DayOfWeek ) i;
                        s1 = string.Concat( s1, dayHours.ToString( ) + ", Virtual, Full", ";" );
                    }
                }
                if ( ( !cbListVirtualHours[ i ].Checked ) && ( cbListAgentHours[ i ].Checked ) )
                {
                    if ( rbListIncrementalDays[ i ].Checked )
                    {
                        DayOfWeek dayHours = ( DayOfWeek ) i;
                        s1 = string.Concat( s1, dayHours.ToString( ) + ", Agent, Incremental", ";" );
                    }
                    if ( rbListFullDays[ i ].Checked )
                    {
                        DayOfWeek dayHours = ( DayOfWeek ) i;
                        s1 = string.Concat( s1, dayHours.ToString( ) + ", Agent, Full", ";" );
                    }
                }
                if ( ( cbListVirtualHours[ i ].Checked ) && ( cbListAgentHours[ i ].Checked ) )
                {
                    if ( rbListIncrementalDays[ i ].Checked )
                    {
                        DayOfWeek dayHours = ( DayOfWeek ) i;
                        s1 = string.Concat( s1, dayHours.ToString( ) + ", Virtual, Agent, Incremental", ";" );
                    }
                    if ( rbListFullDays[ i ].Checked )
                    {
                        DayOfWeek dayHours = ( DayOfWeek ) i;
                        s1 = string.Concat( s1, dayHours.ToString( ) + ", Virtual, Agent, Full", ";" );
                    }
                }
            }
            if ( ( s1 != string.Empty ) && ( s1 != null ) )
            {
                string str = s1.Substring( 0, s1.Length - 1 );
                t.Rows.Add( buildSummary( uiDdlBackupHours.SelectedItem.Text.Trim( ) + " : " + str ) );
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelBackupSchedule = string.Empty;
                uiSummaryBackup.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelBackupSchedule = panelsToHtmlString( p );
                uiSummaryBackup.Controls.Clear( );
                uiSummaryBackup.Controls.Add( p );
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_DisasterRecovery( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( arg.Equals( uiDisasterRecovery.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = uiPnlDisasterRecovery.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            // replication requested
            t.Rows.Add( buildSummary( uiValDisasterRecoveryRequested ) );

            if ( uiValDisasterRecoveryRequested.Checked )
            {
                if ( uiValDisasterRecoveryReplicationType.SelectedItem != null )
                {
                    if ( uiValDisasterRecoveryReplicationType.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelDRReplicationType>( ).DRReplicationTypeDescrRqd.Value == false )
                        // other
                        t.Rows.Add( buildSummary( uiLblDisasterRecoveryReplicationType, uiValDisasterRecoveryReplicationType ) );
                    else
                    {
                        // replication type
                        t.Rows.Add( buildSummary( uiLblDisasterRecoveryReplicationType, uiValDisasterRecoveryReplicationType ) );
                        t.Rows.Add( buildSummary( uiLblDisasterRecoveryReplicationTypeOther, uiValDisasterRecoveryReplicationTypeOther ) );
                    }
                }
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelDisasterRecovery = string.Empty;
                uiSummaryDisasterRecovery.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelDisasterRecovery = panelsToHtmlString( p );
                uiSummaryDisasterRecovery.Controls.Clear( );
                uiSummaryDisasterRecovery.Controls.Add( p );

            }
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_HardDrives( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( arg.Equals( uiHardDrives.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = uiPnlHardDrives.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            t.Rows.Add( buildSummary( objAddPanel.dftDrive + " " + objAddPanel.dtfName + " : " + objAddPanel.dftSize.ToString( ) + "GB" ) );

            foreach ( RepeaterItem item in repeaterHardDrive.Items )
            {
                DropDownList drive = ( DropDownList ) item.FindControl( "uidropDownDrive" );
                TextBox name = ( TextBox ) item.FindControl( "Name" );
                TextBox size = ( TextBox ) item.FindControl( "uiTbHardDriveSize" );
                RadioButton Dependent = ( RadioButton ) item.FindControl( "uiRbHardDriveDependent" );
                RadioButton InDependent = ( RadioButton ) item.FindControl( "uiRbHardDriveIndependent" );
                if ( ( size.Text != string.Empty ) && ( name.Text != string.Empty ) )
                {
                    if ( Dependent.Checked )
                    {
                        t.Rows.Add( buildSummary( drive.SelectedItem.Text + " " + name.Text + " : " + size.Text.Trim( ) + "GB" + " {" + Dependent.Text + "}" ) );
                    }
                    if ( InDependent.Checked )
                    {
                        t.Rows.Add( buildSummary( drive.SelectedItem.Text + " " + name.Text + " : " + size.Text.Trim( ) + "GB" + " {" + InDependent.Text + "}" ) );
                    }
                }
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelHardDrive = string.Empty;
                uiSummaryHardDrives.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelHardDrive = panelsToHtmlString( p );
                uiSummaryHardDrives.Controls.Clear( );
                uiSummaryHardDrives.Controls.Add( p );
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_NetworkConnections( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( arg.Equals( uiNetworkConnections.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = uiPnlNetworkConnections.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            if ( uiValNetworkConnectionsType.SelectedItem != null )
            {
                // type
                if ( uiValNetworkConnectionsType.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<StifelNetworkConnectionTypeSerializable>( ).ncTypeDscReq == false )
                    // other
                    t.Rows.Add( buildSummary( uiLblNetworkConnectionsType, uiValNetworkConnectionsType ) );
                else
                {
                    // replication type
                    t.Rows.Add( buildSummary( uiLblNetworkConnectionsType, uiValNetworkConnectionsType ) );
                    t.Rows.Add( buildSummary( uiLblNetworkConnectionTypeOther, uiValNetworkConnectionTypeOther ) );
                }
            }
            if ( uiDdlVlanClusters.SelectedItem != null )
            {
                if ( ( uiDdlVlanClusters.SelectedItem.Text == string.Empty ) )
                {
                }
                else
                {
                    t.Rows.Add( buildSummary( uiLitVlanClusters.Text + uiDdlVlanClusters.SelectedItem.Text.Trim( ) ) );
                }
            }

            if ( uiDdlVlan.SelectedItem != null )
            {
                if ( ( uiDdlVlan.SelectedItem.Text != string.Empty ) && ( uiDdlLocation.SelectedItem.Text != string.Empty ) )
                {
                    t.Rows.Add( buildSummary( uiLitVlan.Text + uiDdlVlan.SelectedItem.Text.Trim( ) ) );
                }
            }

            if ( uiValNetworkConnectionsNumber.SelectedItem != null )
            {
                // number

                if ( uiValNetworkConnectionsNumber.SelectedItem.Text.ToInt32( ) > 1 )
                {
                    t.Rows.Add( buildSummary( uiLblNetworkConnectionsNumber, uiValNetworkConnectionsNumber ) );
                    t.Rows.Add( buildSummary( uiLitReasonNc.Text.Trim( ) + " " + uiTbReasonNc.Text.Trim( ) ) );
                }
                else
                {
                    t.Rows.Add( buildSummary( uiLblNetworkConnectionsNumber, uiValNetworkConnectionsNumber ) );
                }
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelNterworkConnection = string.Empty;
                uiSummaryNetworkConnections.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelNterworkConnection = panelsToHtmlString( p );
                uiSummaryNetworkConnections.Controls.Clear( );
                uiSummaryNetworkConnections.Controls.Add( p );
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_Notes( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            if ( arg.Equals( uiNotes.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            string s = uiValNotes.Text.Trim( );

            Panel p = new Panel
            {
                GroupingText = uiPnlNotes.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            // notes
            if ( ( s != null ) && ( s != string.Empty ) )
            {
                t.Rows.Add( buildSummary( s ) );
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelNotes = string.Empty;
                uiSummaryNotes.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelNotes = panelsToHtmlString( p );
                uiSummaryNotes.Controls.Clear( );
                uiSummaryNotes.Controls.Add( p );
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_ServerBasics( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            if ( arg.Equals( uiServerBasics.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = uiPnlServerBasics.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            // server name
            t.Rows.Add( buildSummary( uiLblServerName, uiValServerName ) );

            //server Description

            t.Rows.Add( buildSummary( uiServerDescription, uiValSeverDescription ) );

            // Operating System
            t.Rows.Add( buildSummary( uiLblOperatingSystem, uiValOperatingSystem ) );
            if ( uiValOperatingSystem.SelectedItem != null )
            {
                if ( ( uiValOperatingSystem.SelectedItem.Text != null ) && ( uiValOperatingSystem.SelectedItem.Text != string.Empty ) )
                {
                    SerializableStifelOS o = uiValOperatingSystem.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( );
                    if ( o.LegacyOS.HasValue )
                    {
                        if ( o.LegacyOS.Value == true )
                        {
                            t.Rows.Add( buildSummary( uiLblOSReason.Text + " " + uiTbReasonOs.Text.Trim( ) ) );
                        }
                    }
                }
            }

            // Memory
            t.Rows.Add( buildSummary( uiLblMemory, uiValMemory ) );

            // CPUs
            t.Rows.Add( buildSummary( uiLblCPUs, uiValCPUs ) );

            //Location
            if ( uiDdlLocation.SelectedItem.Text.Trim( ) == string.Empty )
                t.Rows.Add( buildSummary( uiLitLocation.Text + " " ) );
            else
                t.Rows.Add( buildSummary( uiLitLocation.Text + " " + uiDdlLocation.SelectedItem.Text.Trim( ) ) );

            // Install updates?
            t.Rows.Add( buildSummary( uiValInstallUpdates ) );

            // Server replacement?
            t.Rows.Add( buildSummary( uiValReplaceExisting ) );
            if ( uiValReplaceExisting.Checked )
                t.Rows.Add( buildSummary( uiLblNameExistingServer, uiValNameExistingServer ) );

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelServerBasics = string.Empty;
                uiSummaryServerBasics.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelServerBasics = panelsToHtmlString( p );
                uiSummaryServerBasics.Controls.Clear( );
                uiSummaryServerBasics.Controls.Add( p );
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void summarize_ServerRoles( string arg )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            if ( arg.Equals( uiServerRoles.ID, StringComparison.OrdinalIgnoreCase ) )
                return;

            Panel p = new Panel
            {
                GroupingText = uiPnlServerRoles.GroupingText
            };
            Table t = new Table( );
            t.Width = new Unit( 100, UnitType.Percentage );

            foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
            {
                CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
                CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
                if ( ( uiCLSubRoles.Items.Count != 0 ) && ( uiCLSubRoles != null ) )
                {
                    bool subRolesSelected = false;
                    foreach ( ListItem li in uiCLSubRoles.Items )
                    {
                        if ( li.Selected == true )
                        {
                            subRolesSelected = true;
                        }
                    }
                    if ( subRolesSelected )
                    {
                        t.Rows.Add( buildSummary( uiCServerRoles.Text.Trim( ) ) );
                        foreach ( ListItem li in uiCLSubRoles.Items )
                        {
                            if ( li.Selected )
                            {
                                t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + li.Text ) );
                            }
                        }
                    }
                }
                else
                {
                    if ( uiCServerRoles.Checked )
                    {
                        t.Rows.Add( buildSummary( uiCServerRoles.Text.Trim( ) ) );
                    }
                }
            }

            if ( t.Rows.Count == 0 )
            {
                objAddPanel.panelServerRoles = string.Empty;
                uiSummaryServerRoles.Controls.Clear( );
            }
            else
            {
                p.Controls.Add( t );
                objAddPanel.panelServerRoles = panelsToHtmlString( p );
                uiSummaryServerRoles.Controls.Clear( );
                uiSummaryServerRoles.Controls.Add( p );
            }

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        //void summarize_ServerRoles( string arg )
        //{
        //    AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
        //    if ( arg.Equals( uiServerRoles.ID, StringComparison.OrdinalIgnoreCase ) )
        //        return;
        //    Panel p = new Panel
        //    {
        //        GroupingText = uiPnlServerRoles.GroupingText
        //    };
        //    Table t = new Table( );
        //    t.Width = new Unit( 100, UnitType.Percentage );
        //    // server roles
        //    foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
        //    {
        //        CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
        //        CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
        //        if ( uiCServerRoles.Checked )
        //        {
        //            t.Rows.Add( buildSummary( uiCServerRoles.Text ) );
        //            foreach ( ListItem li in uiCLSubRoles.Items )
        //            {
        //                if ( li.Selected )
        //                {
        //                    t.Rows.Add( buildSummary( "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + li.Text ) );
        //                }
        //            }
        //        }
        //    }
        //    if ( t.Rows.Count == 0 )
        //    {
        //        objAddPanel.panelServerRoles = string.Empty;
        //    }
        //    else
        //    {
        //        p.Controls.Add( t );
        //        objAddPanel.panelServerRoles = panelsToHtmlString( p );
        //        uiSummaryServerRoles.Controls.Clear( );
        //        uiSummaryServerRoles.Controls.Add( p );
        //    }
        //    uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        //}
        string tableclass( )
        {
            //lock ( summaryRow )
            {
                string s = ( ( summaryRow % 2 ) == 0 ) ? CssClass.SummaryRowOdd : CssClass.SummaryRowEven;
                summaryRow++;
                return s;
            }
        }

        void uiDdlBackupHours_Load( )
        {
            StifelBackupHourDao dao = new StifelBackupHourDao( );
            List<StifelBackupHour> listItems = dao.GetAllActiveItems( );
            uiDdlBackupHours.Items.Clear( );
            if ( listItems.Count == 0 )
            {
                uiDdlBackupHours.Items.Add( new ListItem( string.Empty, string.Empty ) );
            }
            else
            {
                uiDdlBackupHours.Items.Add( new ListItem( string.Empty, string.Empty ) );
                foreach ( StifelBackupHour sbh in listItems )
                {
                    uiDdlBackupHours.Items.Add( new ListItem( sbh.Title.ToString( ), sbh.Title.ToString( ) ) );
                }
            }
        }

        void uiDdlBackupHours_Load( string selectedBackupHours )
        {
            StifelBackupHourDao dao = new StifelBackupHourDao( );
            List<StifelBackupHour> listItems = dao.GetAllActiveItems( );
            uiDdlBackupHours.Items.Clear( );
            if ( listItems.Count == 0 )
            {
                uiDdlBackupHours.Items.Add( new ListItem( string.Empty, string.Empty ) );
            }
            else
            {
                uiDdlBackupHours.Items.Add( new ListItem( string.Empty, string.Empty ) );
                foreach ( StifelBackupHour sbh in listItems )
                {
                    ListItem li = new ListItem( sbh.Title.ToString( ), sbh.Title.ToString( ) );
                    li.Selected = sbh.Title.ToString( ).Equals( selectedBackupHours, StringComparison.InvariantCultureIgnoreCase );
                    uiDdlBackupHours.Items.Add( li );
                }
            }
        }

        void uiDdlLocation_Load( )
        {
            StifelVirtualServerLocationDao dao = new StifelVirtualServerLocationDao( );
            List<StifelVirtualServerLocation> list = dao.GetAll( );
            uiDdlLocation.Items.Clear( );
            uiDdlLocation.Items.Add( new ListItem( string.Empty, string.Empty ) );
            foreach ( StifelVirtualServerLocation l in list )
            {
                StifelVirtualServerLocationSerizable svslSerializable = l.ToSerializable( );
                uiDdlLocation.Items.Add( new ListItem( l.CityState, svslSerializable.SerializeToXml<StifelVirtualServerLocationSerizable>( ).ToBase64String( ) ) );
            }
        }

        void uiDdlLocation_Load( Guid selectedItemId )
        {
            StifelVirtualServerLocationDao dao = new StifelVirtualServerLocationDao( );
            List<StifelVirtualServerLocation> list = dao.GetAll( );
            uiDdlLocation.Items.Clear( );
            uiDdlLocation.Items.Add( new ListItem( string.Empty, string.Empty ) );
            foreach ( StifelVirtualServerLocation l in list )
            {
                StifelVirtualServerLocationSerizable svslSerializable = l.ToSerializable( );
                Guid checkSelected = svslSerializable.UniqueId;
                ListItem li = new ListItem( l.CityState, svslSerializable.SerializeToXml<StifelVirtualServerLocationSerizable>( ).ToBase64String( ) );
                li.Selected = checkSelected == selectedItemId;
                uiDdlLocation.Items.Add( li );
            }
        }

        void uiDdlVlanCluster_Load( StifelNetworkConnectionTypeSerializable ncTypeSerializableSelected, string selectedCluster )
        {
            uiDdlVlanClusters.Items.Clear( );
            if ( ncTypeSerializableSelected.ncTypeVlanClusters.Count == 1 )
            {
                showVlanClusters( );
                foreach ( string s in ncTypeSerializableSelected.ncTypeVlanClusters )
                {
                    ListItem li = new ListItem( s, s );
                    li.Selected = true;
                    uiDdlVlanClusters.Items.Add( li );
                }
            }
            else if ( ncTypeSerializableSelected.ncTypeVlanClusters.Count > 1 )
            {
                showVlanClusters( );
                uiDdlVlanClusters.Items.Add( new ListItem( string.Empty, string.Empty ) );
                foreach ( string s in ncTypeSerializableSelected.ncTypeVlanClusters )
                {
                    ListItem li = new ListItem( s, s );
                    li.Selected = s.Equals( selectedCluster, StringComparison.InvariantCultureIgnoreCase );
                    uiDdlVlanClusters.Items.Add( li );
                }
            }
            else
            {
                hideVlanCluters( );
                uiDdlVlanClusters.Items.Add( new ListItem( string.Empty, string.Empty ) );
            }
        }

        void uiDdlVlan_Load( string location, string vlanCluster, string selectedVlan )
        {
            if ( ( location == string.Empty ) || ( vlanCluster == string.Empty ) )
            {
                hideVlanInfo( );
                uiDdlVlan.Items.Clear( );
                uiDdlVlan.Items.Add( new ListItem( string.Empty, string.Empty ) );
            }
            else
            {
                showVlanInfo( );
                uiDdlVlan.Items.Clear( );
                StifelVLANDao dao = new StifelVLANDao( );
                List<StifelVLAN> stifelVlan = dao.GetByLocationAndCluster( location, vlanCluster );
                if ( stifelVlan.Count == 0 )
                {
                    hideVlanInfo( );
                    uiDdlVlan.Items.Clear( );
                    uiDdlVlan.Items.Add( new ListItem( string.Empty, string.Empty ) );
                }
                else if ( stifelVlan.Count == 1 )
                {
                    foreach ( StifelVLAN stifelVlanItem in stifelVlan )
                    {
                        if ( ( stifelVlanItem.Title != null ) && ( stifelVlanItem.Title != string.Empty ) )
                        {
                            StifelVLANSerializable stifelVlanSerializable = stifelVlanItem.ToSrializable( );
                            uiDdlVlan.Items.Add( new ListItem( stifelVlanSerializable.stifelVlanInfo, stifelVlanSerializable.SerializeToXml<StifelVLANSerializable>( ).ToBase64String( ) ) );
                        }
                    }
                }
                else
                {
                    uiDdlVlan.Items.Add( new ListItem( string.Empty, string.Empty ) );
                    foreach ( StifelVLAN stifelVlanItem in stifelVlan )
                    {
                        if ( ( stifelVlanItem.Title != null ) && ( stifelVlanItem.Title != string.Empty ) )
                        {
                            StifelVLANSerializable stifelVlanSerializable = stifelVlanItem.ToSrializable( );
                            ListItem li = new ListItem( stifelVlanSerializable.stifelVlanInfo, stifelVlanSerializable.SerializeToXml<StifelVLANSerializable>( ).ToBase64String( ) );
                            li.Selected = selectedVlan.Equals( stifelVlanSerializable.stifelVlanInfo, StringComparison.InvariantCultureIgnoreCase );
                            uiDdlVlan.Items.Add( li );
                        }
                    }
                }
            }
        }

        void uiRolesForAccess_Load( )
        {
            StifelUserTypeDao userTypeDao = new StifelUserTypeDao( );
            List<StifelUserType> list = userTypeDao.GetAll( );
            uiRoles.Items.Clear( );
            uiRoles.Items.Add( string.Empty );
            foreach ( StifelUserType o in list )
            {
                uiRoles.Items.Add( new ListItem( o.Title, o.SerializeToXml<StifelUserType>( ).ToBase64String( ) ) );
            }
        }

        void uiRoles_Load( SerializableStifelOS value )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            List<string> srvRole = new List<string>( );

            if ( value.Server.Value == true )
            {
                uiBtnServerRoles.Enabled = true;
                settingNestedServerRoles( value.ServerRoles );
            }
            else
            {
                uiBtnServerRoles.Enabled = false;
            }
            //ServerRoleValidation( );
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        void uiRoles_Load( SerializableStifelOS value, List<ServerRolesAndSubRoles> RolesAndSubRoles )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );

            StifelOSDao dao = new StifelOSDao( );
            StifelOS o = dao.Get( uiValOperatingSystem.SelectedItem.Text.Trim( ) );

            if ( value.Server.Value == true )
            {
                uiBtnServerRoles.Enabled = true;
                settingNestedServerRoles( o.ServerRoles );

                foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
                {
                    CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
                    CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
                    foreach ( ServerRolesAndSubRoles Sbr in RolesAndSubRoles )
                    {
                        if ( Sbr.ServerRole == uiCServerRoles.Text )
                        {
                            uiCServerRoles.Checked = true;
                            if ( ( Sbr.SubRoles != null ) && ( Sbr.SubRoles.Count != 0 ) )
                            {
                                foreach ( string s in Sbr.SubRoles )
                                {
                                    foreach ( ListItem li in uiCLSubRoles.Items )
                                    {
                                        if ( s == li.Text )
                                        {
                                            li.Selected = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                uiBtnServerRoles.Enabled = false;
            }

            // ServerRoleValidation( );
            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        //void uiRoles_Load( SerializableStifelOS value )
        //{
        //    AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
        //    List<string> srvRole = new List<string>( );
        //    if ( value.Server.Value == true )
        //    {
        //        uiBtnServerRoles.Enabled = true;
        //        settingNestedServerRoles(value.ServerRoles );
        //    }
        //    else
        //    {
        //        uiBtnServerRoles.Enabled = false;
        //    }
        //    ServerRoleValidation( );
        //    uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        //}
        //void uiRoles_Load( List<string> Roles, SerializableStifelOS value, List<ServerRolesAndSubRoles> SubRoles )
        //{
        //    AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
        //    List<string> srvRole = new List<string>( );
        //    if ( value.Server.Value == true )
        //    {
        //        uiBtnServerRoles.Enabled = true;
        //        settingNestedServerRoles( value.ServerRoles );
        //        foreach ( RepeaterItem r in uiServerRolesRepeater.Items )
        //        {
        //            CheckBox uiCServerRoles = ( CheckBox ) r.FindControl( "uiServerRoles" );
        //            CheckBoxList uiCLSubRoles = ( CheckBoxList ) r.FindControl( "uiSubRoles" );
        //            foreach ( ServerRolesAndSubRoles Sbr in SubRoles )
        //            {
        //                if ( Sbr.ServerRole == uiCServerRoles.Text )
        //                {
        //                    uiCServerRoles.Checked = true;
        //                    foreach ( string s in Sbr.SubRoles )
        //                    {
        //                        foreach ( ListItem li in uiCLSubRoles.Items )
        //                        {
        //                            if ( s == li.Text )
        //                            {
        //                                li.Selected = true;
        //                            }
        //                        }
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    else
        //    {
        //        uiBtnServerRoles.Enabled = false;
        //    }
        //    ServerRoleValidation( );
        //    uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        //}
        void uiValCPUs_Load( SerializableStifelOS value )
        {
            int dft = value.DftCPU.HasValue ? value.DftCPU.Value.ToInt32( ) : 1;
            int max = value.MaxCPU.HasValue ? value.MaxCPU.Value.ToInt32( ) : 1;

            uiValCPUs.Items.Clear( );
            {
                ListItem item = new ListItem( 1.ToString( ) );
                item.Selected = 1 == dft;
                uiValCPUs.Items.Add( item );
            }
            for ( int i = 2; i <= max; i += 2 )
            {
                ListItem item = new ListItem( i.ToString( ) );
                item.Selected = i == dft;
                uiValCPUs.Items.Add( item );
            }
        }

        bool isOsReasonValidated( )
        {
            bool ok = false;
            if ( uiValOperatingSystem.SelectedItem != null )
            {
                if ( ( uiValOperatingSystem.SelectedItem.Text != null ) && ( uiValOperatingSystem.SelectedItem.Text != string.Empty ) )
                {
                    SerializableStifelOS p = uiValOperatingSystem.SelectedItem.Value.FromBase64String( ).DeserializeFromXml<SerializableStifelOS>( );
                    if ( p.LegacyOS.HasValue )
                    {
                        if ( p.LegacyOS.Value == true )
                        {
                            if ( ( uiTbReasonOs.Text == null ) || ( uiTbReasonOs.Text == string.Empty ) )
                            {
                                ok = true;
                            }
                        }
                    }
                }
            }
            return ok;
        }

        void setOsReasonVisible( )
        {
            uiLblOSReason.Visible = true;
            uiTbReasonOs.Visible = true;
        }
        void setOsReasonHide( )
        {
            uiLblOSReason.Visible = false;
            uiTbReasonOs.Visible = false;
            uiTbReasonOs.Text = string.Empty;
            uiLblOsReasonErrorMsg.Text = string.Empty;
        }

        void uiValCPUs_Load( int selectedVal, SerializableStifelOS value )
        {
            int dft = selectedVal;
            int max = value.MaxCPU.HasValue ? value.MaxCPU.Value.ToInt32( ) : 1;

            uiValCPUs.Items.Clear( );
            {
                ListItem item = new ListItem( 1.ToString( ) );
                item.Selected = 1 == dft;
                uiValCPUs.Items.Add( item );
            }
            for ( int i = 2; i <= max; i += 2 )
            {
                ListItem item = new ListItem( i.ToString( ) );
                item.Selected = i == dft;
                uiValCPUs.Items.Add( item );
            }
        }

        void uiValDisasterRecoveryReplicationType_Load( )
        {
            StifelDRReplicationTypeDao replicationTypeDao = new StifelDRReplicationTypeDao( );
            List<StifelDRReplicationType> replicationTypeList = replicationTypeDao.GetAll( );
            uiValDisasterRecoveryReplicationType.Items.Clear( );
            ListItem i = new ListItem( );
            foreach ( StifelDRReplicationType rt in replicationTypeList )
            {
                ListItem item = new ListItem( rt.Title, rt.SerializeToXml<StifelDRReplicationType>( ).ToBase64String( ) );
                item.Selected = rt.DftDRReplicationType.HasValue ? rt.DftDRReplicationType.Value : false;
                uiValDisasterRecoveryReplicationType.Items.Add( item );
            }
            uiValDisasterRecoveryReplicationTypeOther.Visible = false;
            uiLblDisasterRecoveryReplicationTypeOther.Visible = false;
            uiDisasterRecoveryFlag.Visible = false;
        }

        void uiValDisasterRecoveryReplicationType_Load( string selectedVal )
        {
            string dft = selectedVal;
            StifelDRReplicationTypeDao replicationTypeDao = new StifelDRReplicationTypeDao( );
            List<StifelDRReplicationType> replicationTypeList = replicationTypeDao.GetAll( );
            uiValDisasterRecoveryReplicationType.Items.Clear( );
            foreach ( StifelDRReplicationType rt in replicationTypeList )
            {
                ListItem item = new ListItem( rt.Title, rt.SerializeToXml<StifelDRReplicationType>( ).ToBase64String( ) );
                item.Selected = rt.Title == dft;
                uiValDisasterRecoveryReplicationType.Items.Add( item );
            }
            if ( uiValDisasterRecoveryReplicationType.SelectedItem.Value.ToString( ).FromBase64String( ).DeserializeFromXml<StifelDRReplicationType>( ).DRReplicationTypeDescrRqd.HasValue )
            {
                uiValDisasterRecoveryReplicationTypeOther.Visible = true;
                uiLblDisasterRecoveryReplicationTypeOther.Visible = true;
                uiDisasterRecoveryFlag.Visible = true;
            }
        }

        void uiValMemory_Load( SerializableStifelOS value )
        {
            int dft = value.DftMemoryGB.HasValue ? value.DftMemoryGB.Value.ToInt32( ) : 2;
            int max = value.MaxMemoryGB.HasValue ? value.MaxMemoryGB.Value.ToInt32( ) : 2;

            uiValMemory.Items.Clear( );
            for ( int i = 2; i <= max; i += 2 )
            {
                ListItem item = new ListItem( i.ToString( ) );
                item.Selected = i == dft;
                uiValMemory.Items.Add( item );
            }
        }

        void uiValMemory_Load( int selectedVal, SerializableStifelOS value )
        {
            int dft = selectedVal;

            int max = value.MaxMemoryGB.HasValue ? value.MaxMemoryGB.Value.ToInt32( ) : 2;

            uiValMemory.Items.Clear( );
            for ( int i = 2; i <= max; i += 2 )
            {
                ListItem item = new ListItem( i.ToString( ) );
                item.Selected = i == dft;
                uiValMemory.Items.Add( item );
            }
        }

        void uiValNetworkConnectionsNumber_Load( SerializableStifelOS value )
        {
            int dft = 1; //value.DftNetworkConnections.HasValue ? value.DftNetworkConnections.Value.ToInt32( ) : 1;
            int max = value.MaxNetworkConnections.HasValue ? value.MaxNetworkConnections.Value.ToInt32( ) : 1;
            uiValNetworkConnectionsNumber.Items.Clear( );
            for ( int i = 1; i <= max; i += 1 )
            {
                ListItem item = new ListItem( i.ToString( ) );
                item.Selected = i == dft;
                uiValNetworkConnectionsNumber.Items.Add( item );
            }
        }

        void uiValNetworkConnectionsNumber_Load( int selectedVal, SerializableStifelOS value )
        {
            int dft = selectedVal;
            int max = value.MaxNetworkConnections.HasValue ? value.MaxNetworkConnections.Value.ToInt32( ) : 4;
            uiValNetworkConnectionsNumber.Items.Clear( );
            for ( int i = 1; i <= max; i += 1 )
            {
                ListItem item = new ListItem( i.ToString( ) );
                item.Selected = i == dft;
                uiValNetworkConnectionsNumber.Items.Add( item );
            }
        }

        void uiValNetworkConnectionsType_Load( SerializableStifelOS value )
        {
            StifelNetworkConnectionTypeDao networkTypeDao = new StifelNetworkConnectionTypeDao( );
            List<StifelNetworkConnectionType> networkTypeList = networkTypeDao.GetAll( );
            uiValNetworkConnectionsType.Items.Clear( );
            foreach ( StifelNetworkConnectionType nt in networkTypeList )
            {
                if ( value.Server.Value == nt.NetworkConnectionTypeServer.Value )
                {
                    ListItem item = new ListItem( nt.Title, nt.SerializeToXml<StifelNetworkConnectionType>( ).ToBase64String( ) );
                    item.Selected = nt.NetworkConnectionTypeDft.HasValue ? nt.NetworkConnectionTypeDft.Value : false;
                    uiValNetworkConnectionsType.Items.Add( item );
                }
            }
            uiLblNetworkConnectionTypeOther.Visible = false;
            uiValNetworkConnectionTypeOther.Visible = false;
            uiNetworkConnectionDescriptionFlag.Visible = false;
        }

        void uiValNetworkConnectionsType_Load( string selectedVal, SerializableStifelOS value )
        {
            string dft = selectedVal;
            StifelNetworkConnectionTypeDao networkTypeDao = new StifelNetworkConnectionTypeDao( );
            List<StifelNetworkConnectionType> networkTypeList = networkTypeDao.GetAll( );
            uiValNetworkConnectionsType.Items.Clear( );
            foreach ( StifelNetworkConnectionType nt in networkTypeList )
            {
                StifelNetworkConnectionTypeSerializable SncTypeSerilizable = nt.ToSrializable( );
                if ( value.Server.Value == nt.NetworkConnectionTypeServer.Value )
                {
                    ListItem item = new ListItem( nt.Title, SncTypeSerilizable.SerializeToXml<StifelNetworkConnectionTypeSerializable>( ).ToBase64String( ) );
                    item.Selected = nt.Title == dft;
                    uiValNetworkConnectionsType.Items.Add( item );
                }
            }

            if ( uiValNetworkConnectionsType.SelectedItem.Value.ToString( ).FromBase64String( ).DeserializeFromXml<StifelNetworkConnectionTypeSerializable>( ).ncTypeDscReq == true )
            {
                uiLblNetworkConnectionTypeOther.Visible = true;
                uiValNetworkConnectionTypeOther.Visible = true;
                uiNetworkConnectionDescriptionFlag.Visible = true;
            }
        }

        void uiValOperatingSystem_load( string selectedVal )
        {
            AddPanel objAddPanel = uiObjAddPanel.Value.FromBase64String( ).DeserializeFromXml<AddPanel>( );
            StifelOSDao dao = new StifelOSDao( );
            List<StifelOS> list = dao.GetAllWithOutRoles( );
            uiValOperatingSystem.Items.Clear( );
            foreach ( StifelOS o in list )
            {
                ListItem item = new ListItem( o.Title, o.ToSerializableStifelOS( ).SerializeToXml<SerializableStifelOS>( ).ToBase64String( ) );
                item.Selected = o.Title == selectedVal;
                uiValOperatingSystem.Items.Add( item );
            }
            objAddPanel.hiddenValOperatingSystem = uiValOperatingSystem.SelectedItem.Value;

            uiObjAddPanel.Value = objAddPanel.SerializeToXml<AddPanel>( ).ToBase64String( );
        }

        #endregion Methods

        #region Nested Types

        class Attribute
        {
            #region Fields

            public const string Current = "current";

            #endregion Fields
        }

        class CssClass
        {
            #region Fields

            public const string Data = "data";
            public const string Label = "label";
            public const string SummaryRowEven = "d1";
            public const string SummaryRowOdd = "d0";

            #endregion Fields
        }

        class TextAlign
        {
            #region Fields

            public const string Left = "left";
            public const string Right = "right";
            public const string summaryAdjustLeftPart = "summaryAdjustLeftPart";
            public const string summaryAdjustRightPart = "summaryAdjustRightPart";

            #endregion Fields
        }

        #endregion Nested Types
    }
}